Web/API/WebSocket/readyState

From Get docs

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:

Value State Description
0 CONNECTING Socket has been created. 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 StandardThe definition of 'WebSocket: readyState' in that specification. Living Standard Initial definition

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
readyState Chrome

Full support 43

Edge

Full support 12

Firefox

Full support 19

IE

Full support 10

Opera

Full support 30

Safari

Full support 10

WebView Android

Full support 43

Chrome Android

Full support 43

Firefox Android

Full support 19

Opera Android

Full support 30

Safari iOS

Full support 10

Samsung Internet Android

Full support 4.0

Legend

Full support  
Full support