Response message: Received: Close frame with status code 1009 and close reason 'No async message support and buffer too small. Buffer size: [8,192], Message size: [51,926]'
Disconnect the reason
There are many reasons WebSocket disconnection of the best in the WebSocket disconnection, print out the error.
ws.onclose = function (e) { console.log('websocket 断开: ' + e.code + ' ' + e.reason + ' ' + e.wasClean) console.log(e) }
Error status code:
WebSocket disconnection when triggered CloseEvent
, CloseEvent use WebSockets will be sent to the client when the connection is closed. It uses the WebSocket object onclose event listener. CloseEvent the code field indicates the reason WebSocket disconnection. Causes may be disconnected from the field.
CloseEvent has three fields should be noted, by analyzing these three fields, you can usually find a disconnect reason
CloseEvent.code
: Code is error code is an integer typeCloseEvent.reason
: Reason is the reason for disconnection, a stringCloseEvent.wasClean
: WasClean representation is normally disconnected, it is a Boolean value. When disconnected abnormally general, the value is false
status code | name | description |
---|---|---|
0–999 | Retention period, unused. | |
1000 | CLOSE_NORMAL | Normally closed; no matter what the purpose of creation, the links have completed the task successfully. |
1001 | CLOSE_GOING_AWAY | Terminal leave, probably because the server error, or because the browser to jump from page to open the connection being left. |
1002 | CLOSE_PROTOCOL_ERROR | Since the protocol error interrupted the connection. |
1003 | CLOSE_UNSUPPORTED | Since the type of the received data is not allowed and disconnected (e.g., the terminal receives only the text data received binary data). |
1004 | 保留 Its significance may be defined in the future. |
|
1005 | CLOSE_NO_STATUS | 保留 . I have not received the expected status code. |
1006 |
CLOSE_ABNORMAL | 保留 . For the desired connection closed abnormally received status code (i.e., no transmission frame is closed). |
1007 | Unsupported Data | Since the received data does not match the format disconnected (such as a text message contains a non-UTF-8 data). |
1008 | Policy Violation | Since the received data is non-conforming and disconnected. This is a general status code, use scenarios for an inappropriate status codes 1003 and 1009. |
1009 | CLOSE_TOO_LARGE | Since large data received frames disconnected. |
1010 | Missing Extension | The client agreed on one or more servers expect to expand, but the server does not handle, so the client disconnects. |
1011 | Internal Error | The client encountered due to unexpected circumstances prevented its completion request, so the server is disconnected. |
1012 | Service Restart | Since reboot the server was disconnected. |
1013 | Try Again Later | Due to a temporary reason the server is disconnected, such disconnection overloading the server so clients connecting portion. |
1014 | Retained by the WebSocket standard for future use. | |
1015 | TLS Handshake | Reserved. Indicates that the connection can not be completed because the TLS handshake to close (for example, unable to validate the server certificate). |
1016–1999 | Retained by the WebSocket standard for future use. | |
2000–2999 | Reserved for use by the WebSocket expand. | |
3000–3999 | It can be used by libraries or frameworks.? Should not be. You can register by applications in IANA, first-served basis. | |
4000–4999 | It can be used by the application. |