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;