The WebRTC API's RTCPeerConnection
interface offers the restartIce()
method to allow a web application to easily request that ICE candidate gathering be redone on both ends of the connection. This simplifies the process by allowing the same method to be used by either the caller or the receiver to trigger an ICE restart.
After restartIce()
returns, the offer returned by the next call to createOffer()
is automatically configured to trigger ICE restart on both the local peer (once the local peer has been set) and on the remote peer, once the offer is sent across your signaling mechanism and the remote peer has set its description as well.
restartIce()
causes the negotiationneeded
event to be fired on the RTCPeerConnection
to inform the application that it should perform negotiation using its signaling channel.
If negotiation fails to complete—either due to rollback or because incoming offers are in the process of being negotiated—the RTCPeerConnection
will remember that you requested ICE restart. The next time the connection's signalingState
changes to stable
, the connection will fire the negotiationneeded
event. This process continues until an ICE restart has been successfully completed.