From d3655b8955181bf0f4c62d56c7d4e382e8289ce4 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Wed, 10 Jun 2020 14:34:43 +0200 Subject: [PATCH] Handle client-side errors during negotiation. --- static/sfu.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/static/sfu.js b/static/sfu.js index e78d7de..9872436 100644 --- a/static/sfu.js +++ b/static/sfu.js @@ -736,7 +736,14 @@ async function gotAnswer(id, answer) { let c = up[id]; if(!c) throw new Error('unknown up stream'); - await c.pc.setRemoteDescription(answer); + try { + await c.pc.setRemoteDescription(answer); + } catch(e) { + console.error(e); + displayError(e); + delUpMedia(id); + return; + } await addIceCandidates(c); } @@ -1117,7 +1124,15 @@ async function newUpStream() { throw new Error("Couldn't create peer connection"); up[id] = new Connection(id, pc); - pc.onnegotiationneeded = e => negotiate(id); + pc.onnegotiationneeded = async e => { + try { + await negotiate(id); + } catch(e) { + console.error(e); + displayError(e); + delUpMedia(id); + } + } pc.onicecandidate = function(e) { if(!e.candidate)