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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
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
WebSocket.readyState by Mozilla Contributors is licensed under CC-BY-SA 2.5.