RTCPeerConnection: iceconnectionstatechange event

An iceconnectionstatechange event is sent to an RTCPeerConnection object each time the ICE connection state changes during the negotiation process. The new ICE connection state is available in the object's iceConnectionState} property.

Bubbles No
Cancelable No
Interface Event
Event handler property oniceconnectionstatechange

One common task performed by the iceconnectionstatechange event listener: to trigger ICE restart when the state changes to failed. See ICE restart in Lifetime of a WebRTC session for further information.


An event handler for this event can be added using the RTCPeerConnection.oniceconnectionstatechange property or by using addEventListener() on the RTCPeerConnection.

In this example, a handler for iceconnectionstatechange is set up to cleanly shut down a conference call when the ICE connection enters the disconnected state.

pc.addEventListener("iceconnectionstatechange", ev => {
  if (pc.iceConnectionState === "disconnected") {
    closeVideoCall(pc);  // Our code to shut down the call
}, false);

This can also be written as:

pc.oniceconnectionstatechange = ev => {
  if (pc.iceConnectionState === "disconnected") {
    closeVideoCall(pc);  // Our code to shut down the call


Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'iceconnectionstatechange' in that specification.
Candidate Recommendation Ā 

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
iceconnectionstatechange eventChrome Full support 28Edge Full support 15Firefox Full support 22IE No support NoOpera Full support 43Safari Full support 11WebView Android Full support YesChrome Android Full support 28Firefox Android Full support 44Opera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0


Full support Ā 
Full support
No support Ā 
No support
Compatibility unknown Ā 
Compatibility unknown

See also