From 4b32c55a57caff674e3404785826cb51b9d1bfeb Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Thu, 11 Jun 2020 19:11:36 +0200 Subject: [PATCH] Restart ICE in client on up connection failures. --- static/sfu.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/static/sfu.js b/static/sfu.js index 9bec93f..554c1fa 100644 --- a/static/sfu.js +++ b/static/sfu.js @@ -1168,7 +1168,7 @@ async function newUpStream(id) { } } - pc.onicecandidate = function(e) { + pc.onicecandidate = e => { if(!e.candidate) return; send({type: 'ice', @@ -1177,6 +1177,17 @@ async function newUpStream(id) { }); }; + pc.oniceconnectionstatechange = e => { + if(pc.iceConnectionState === 'failed') { + try { + pc.restartIce(); + } catch(e) { + console.error(e); + displayError(e); + } + } + } + pc.ontrack = console.error; return id;