WebSocket.readyState

The WebSocket.readyState read-only property returns the current state of the WebSocket connection.

Syntax

var readyState = aWebSocket.readyState;

Value

One of the following unsigned short values:

0 (CONNECTING)
The connection is not yet open.
1 (OPEN)
The connection is open and ready to communicate.
2 (CLOSING)
The connection is in the process of closing.
3 (CLOSED)
The connection is closed or couldn't be opened.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'WebSocket: readyState' in that specification.
Living Standard Initial definition

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge ? Firefox Full support YesIE ? Opera Full support YesSafari ? WebView Android ? Chrome Android Full support YesEdge Mobile ? Firefox Android Full support YesOpera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

Document Tags and Contributors

Contributors to this page: sideshowbarker, fscholz, Claas
Last updated by: sideshowbarker,