diff --git a/internal/servers/webrtc/publish_index.html b/internal/servers/webrtc/publish_index.html index 8298117502d..8176a664c6a 100644 --- a/internal/servers/webrtc/publish_index.html +++ b/internal/servers/webrtc/publish_index.html @@ -443,12 +443,16 @@ pc.setRemoteDescription(new RTCSessionDescription({ type: 'answer', sdp, - })); - - if (queuedCandidates.length !== 0) { - sendLocalCandidates(queuedCandidates); - queuedCandidates = []; - } + })) + .then(() => { + if (queuedCandidates.length !== 0) { + sendLocalCandidates(queuedCandidates); + queuedCandidates = []; + } + }) + .catch((err) => { + onError(err.toString()); + }); }; const sendOffer = (offer) => { diff --git a/internal/servers/webrtc/read_index.html b/internal/servers/webrtc/read_index.html index 4839eb879e7..78a2026c61d 100644 --- a/internal/servers/webrtc/read_index.html +++ b/internal/servers/webrtc/read_index.html @@ -254,12 +254,16 @@ pc.setRemoteDescription(new RTCSessionDescription({ type: 'answer', sdp, - })); - - if (queuedCandidates.length !== 0) { - sendLocalCandidates(queuedCandidates); - queuedCandidates = []; - } + })) + .then(() => { + if (queuedCandidates.length !== 0) { + sendLocalCandidates(queuedCandidates); + queuedCandidates = []; + } + }) + .catch((err) => { + onError(err.toString()); + }); }; const sendOffer = (offer) => {