Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

RTCPeerConnection: connectionState property

Baseline2023
Newly available

TheconnectionState read-only property of theRTCPeerConnection interface indicates the current state of the peer connection by returning one of the following string values:new,connecting,connected,disconnected,failed, orclosed.

This state essentially represents the aggregate state of all ICE transports (which are of typeRTCIceTransport orRTCDtlsTransport) being used by the connection.

When this property's value changes, aconnectionstatechange event is sent to theRTCPeerConnection instance.

Value

A string representing the current state of the connection.This can take on of the following values:

new

At least one of the connection'sICE transports (RTCIceTransport orRTCDtlsTransport objects) is in thenew 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 theclosed state.

connecting

One or more of theICE transports are currently in the process of establishing a connection;that is, theiriceConnectionState is eitherchecking orconnected, and no transports are in thefailed state.

connected

EveryICE transport used by the connection is either in use (stateconnected orcompleted) or is closed (stateclosed);in addition, at least one transport is eitherconnected orcompleted.

disconnected

At least one of theICE transports for the connection is in thedisconnected state and none of the other transports are in the states:failed,connecting, orchecking.

failed

One or more of theICE transports on the connection is in thefailed state.

closed

TheRTCPeerConnection is closed.

Example

js
const peerConnection = new RTCPeerConnection(configuration);// …const connectionState = peerConnection.connectionState;

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# dom-peerconnection-connection-state

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp