Proper way to handle ICE restart

2,450 views
Skip to first unread message

Anil Wadghule

unread,
May 16, 2018, 7:38:30 AM5/16/18
to meetecho-janus
Recently in my application, I have added a feature for ICE Restart whenever we detect ICE Connection state as 'disconected'

Basically here is what I do

STEP 1:
if (peerConnection.iceConnectionState === "disconnected") {
    // nothing
    republishForIceRestart();
}

STEP 2:

var republishForIceRestart = function () {
  peerConnection.onicecandidate = function() {
    console.log("no actionTaken on republish for onicecandidate")
  }

  handleIceConnectionStateChange(peerConnection);

  var publisherConstraints = {
  }
  publisherConstraints.iceRestart = true;

    peerConnection
    .createOffer(createdDescriptionIceRestart, errorHandler, publisherConstraints);
}

OBSERVATION:

1. In Janus logs, I see this

[WARN] [1601494747650989] ICE restart detected
[1601494747650989] Restarting ICE...
[8403247280081227] Updating existing session

2. But in Google Chrome's console of the browser on which ICE failed occurred, I see this.

~~~~ Setting up remote description for the received answer from remote
purple-breeze-5946#live:1 Uncaught (in promise) DOMException: Failed to set remote answer sdp: Called in wrong state: kStable

So looks like for the sent offer with iceRestart = true, Janus is sending the answer back and somehow there is an exception in setting up remote answer SDP with setRemoteDescription


Does anyone know if this flow for ICE restart is correct or am I missing anything?


--
Thank you,
Anil

Lorenzo Miniero

unread,
May 16, 2018, 7:43:02 AM5/16/18
to meetecho-janus
Just FYI, ICE restarts only make sense when you were connected (PeerConnection was up) and then it got to failed later on, which means you should track these state changes, and not simply react to a single event out of context. I don't think they're much use when ICE gets to disconnected, as possibly the browser has already cleared the stack at that point.

That said, your error seems to suggest that you're setting an answer but you didn't set an offer for the restart before (maybe you forgot setLocalDescription before sending the SDP to Janus?)

L.

Anil Wadghule

unread,
May 16, 2018, 9:03:39 AM5/16/18
to Lorenzo Miniero, meetecho-janus
Thanks Lorenzo.

Below thread on webrtc-user suggestes ICE restart shoud happen upon detection of ICE state disconnected event.


Also I added logging and can say that I am doing setLocalDescription before sending the SDP to Janus.

Not sure.. what's wrong there.

Thanks,
Anil

--
You received this message because you are subscribed to the Google Groups "meetecho-janus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Best,
Anil

Anil Wadghule

unread,
May 17, 2018, 10:40:05 AM5/17/18
to meetecho-janus
Hello,

I am not able to find much documentation about how to do proper ICE restart in WebRTC..

Anyone here knows any link for more info about it?

Thank you,
Anil

On Wednesday, 16 May 2018 18:33:39 UTC+5:30, Anil Wadghule wrote:
Thanks Lorenzo.

Below thread on webrtc-user suggestes ICE restart shoud happen upon detection of ICE state disconnected event.


Also I added logging and can say that I am doing setLocalDescription before sending the SDP to Janus.

Not sure.. what's wrong there.

Thanks,
Anil

For more options, visit https://groups.google.com/d/optout.


--
Best,
Anil

Lorenzo Miniero

unread,
May 17, 2018, 11:21:57 AM5/17/18
to meetecho-janus

Anil Wadghule

unread,
May 17, 2018, 11:27:37 AM5/17/18
to Lorenzo Miniero, meetecho-janus
Thanks, Lorenzo for the links.

Yes, I have successfully implemented Janus Renegotiation in my application. It works fine.

I went through above appear.in link too. It didn't help much for the ICE Restart I am implementing. Need some example or steps. I am for sure doing something wrong.

Thanks,
Anil

To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janu...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Best,
Anil

Reply all
Reply to author
Forward
0 new messages