docs.rodeo

MDN Web Docs mirror

RTCPeerConnection: iceConnectionState property

{{APIRef("WebRTC")}} 

The iceConnectionState read-only property of the {{domxref("RTCPeerConnection")}}  interface returns a string which state of the {{Glossary("ICE")}}  agent associated with the {{domxref("RTCPeerConnection")}} : new, checking, connected, completed, failed, disconnected, and closed.

It describes the current state of the ICE agent and its connection to the ICE server; that is, the {{Glossary("STUN")}}  or {{Glossary("TURN")}}  server.

You can detect when this value has changed by watching for the {{DOMxRef("RTCPeerConnection.iceconnectionstatechange_event", "iceconnectionstatechange")}}  event.

Value

The current state of the ICE agent and its connection. The value is one of the following strings:

Examples

const pc = new RTCPeerConnection();
const state = pc.iceConnectionState;

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN