Since May 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The connectionState read-only property of the RTCPeerConnection interface indicates the current state of the peer connection by returning one of the following string values: new, connecting, connected, disconnected, failed, or closed.
This state essentially represents the aggregate state of all ICE transports (which are of type RTCIceTransport or RTCDtlsTransport) being used by the connection.
When this property's value changes, a connectionstatechange event is sent to the RTCPeerConnection instance.
A string representing the current state of the connection. This can take on of the following values:
newAt least one of the connection's ICE transports (RTCIceTransport or RTCDtlsTransport objects) is in the new state, and none of them are in one of the following states: connecting, checking, failed, disconnected, or all of the connection's transports are in the closed state.
connectingOne or more of the ICE transports are currently in the process of establishing a connection; that is, their iceConnectionState is either checking or connected, and no transports are in the failed state.
connectedEvery ICE transport used by the connection is either in use (state connected or completed) or is closed (state closed); in addition, at least one transport is either connected or completed.
disconnectedAt least one of the ICE transports for the connection is in the disconnected state and none of the other transports are in the states: failed, connecting, or checking.
failedOne or more of the ICE transports on the connection is in the failed state.
closedThe RTCPeerConnection is closed.
const peerConnection = new RTCPeerConnection(configuration); // … const connectionState = peerConnection.connectionState;
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
connectionState |
72 | 79 | 113 | 60 | 11 | 72 | 113 | 51 | 11 | 11.0 | 72 | 11 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/connectionState