diff --git a/internal/servers/webrtc/publish_index.html b/internal/servers/webrtc/publish_index.html index 82981175..8176a664 100644 --- a/internal/servers/webrtc/publish_index.html +++ b/internal/servers/webrtc/publish_index.html @@ -443,12 +443,16 @@ const onRemoteAnswer = (sdp) => { 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 4839eb87..78a2026c 100644 --- a/internal/servers/webrtc/read_index.html +++ b/internal/servers/webrtc/read_index.html @@ -254,12 +254,16 @@ const onRemoteAnswer = (sdp) => { 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) => {