openvidu-browser: catch unhandled error on RTCPeerConnection#addIceCandidate

pull/771/head
pabloFuente 2022-12-16 16:32:45 +01:00
parent 273520cb2d
commit d6acd0d321
1 changed files with 6 additions and 3 deletions

View File

@ -56,7 +56,6 @@ export class WebRtcPeer {
protected configuration: Required<WebRtcPeerConfiguration>;
private iceCandidateList: RTCIceCandidate[] = [];
private candidategatheringdone = false;
constructor(configuration: WebRtcPeerConfiguration) {
platform = PlatformUtils.getInstance();
@ -91,12 +90,16 @@ export class WebRtcPeer {
}
});
this.pc.addEventListener('signalingstatechange', () => {
this.pc.addEventListener('signalingstatechange', async () => {
if (this.pc.signalingState === 'stable') {
// SDP Offer/Answer finished. Add stored remote candidates.
while (this.iceCandidateList.length > 0) {
let candidate = this.iceCandidateList.shift();
this.pc.addIceCandidate(<RTCIceCandidate>candidate);
try {
await this.pc.addIceCandidate(<RTCIceCandidate>candidate);
} catch (error) {
logger.error('Error when calling RTCPeerConnection#addIceCandidate for RTCPeerConnection ' + this.getId(), error);
}
}
}
});