diff --git a/internal/servers/webrtc/publish_index.html b/internal/servers/webrtc/publish_index.html index 21e1fbe3..122bba6a 100644 --- a/internal/servers/webrtc/publish_index.html +++ b/internal/servers/webrtc/publish_index.html @@ -480,8 +480,16 @@ const createOffer = () => { pc.createOffer() .then((offer) => { offerData = parseOffer(offer.sdp); - pc.setLocalDescription(offer); - sendOffer(offer.sdp); + pc.setLocalDescription(offer) + .then(() => { + sendOffer(offer.sdp); + }) + .catch((err) => { + onError(err.toString()); + }); + }) + .catch((err) => { + onError(err.toString()); }); }; @@ -491,7 +499,7 @@ const onConnectionState = () => { } if (pc.iceConnectionState === 'disconnected') { - onError('peer connection disconnected', true); + onError('peer connection closed', true); } else if (pc.iceConnectionState === 'connected') { setMessage(''); } diff --git a/internal/servers/webrtc/read_index.html b/internal/servers/webrtc/read_index.html index c42e8267..edaa489a 100644 --- a/internal/servers/webrtc/read_index.html +++ b/internal/servers/webrtc/read_index.html @@ -381,8 +381,16 @@ const createOffer = () => { .then((offer) => { offer.sdp = editOffer(offer.sdp); offerData = parseOffer(offer.sdp); - pc.setLocalDescription(offer); - sendOffer(offer); + pc.setLocalDescription(offer) + .then(() => { + sendOffer(offer); + }) + .catch((err) => { + onError(err.toString()); + }); + }) + .catch((err) => { + onError(err.toString()); }); }; @@ -392,7 +400,7 @@ const onConnectionState = () => { } if (pc.iceConnectionState === 'disconnected') { - onError('peer connection disconnected'); + onError('peer connection closed'); } };