WebSocket 1001 Going Away vs 1010 Mandatory Extension
Both WebSocket 1001 (Going Away) and 1010 (Mandatory Extension) belong to the WebSocket Close Codes category. 1001 indicates that an endpoint is going away, such as a server shutting down or a browser navigating away from the page. The connection must be closed. Meanwhile, 1010 means that the client is terminating the connection because the server did not negotiate one or more expected extensions in the handshake response.
Beschreibung
An endpoint is going away, such as a server shutting down or a browser navigating away from the page. The connection must be closed.
Wann Sie es sehen
The server is shutting down for maintenance, or the user navigated away from the page or closed the browser tab while a WebSocket was open.
Wie man es behebt
Implement automatic reconnection logic with exponential backoff in your client. If the server is restarting, the client should retry after a short delay.
Beschreibung
The client is terminating the connection because the server did not negotiate one or more expected extensions in the handshake response.
Wann Sie es sehen
The client requested a required WebSocket extension (e.g., permessage-deflate compression) during the handshake, but the server did not include it in its response.
Wie man es behebt
Enable the required extension on the server, or update the client to make the extension optional. Check the Sec-WebSocket-Extensions header in the handshake response.
Wesentliche Unterschiede
WebSocket 1001: An endpoint is going away, such as a server shutting down or a browser navigating away from the page. The connection must be closed.
WebSocket 1010: The client is terminating the connection because the server did not negotiate one or more expected extensions in the handshake response.
You encounter 1001 when the server is shutting down for maintenance, or the user navigated away from the page or closed the browser tab while a WebSocket was open.
You encounter 1010 when the client requested a required WebSocket extension (e.g., permessage-deflate compression) during the handshake, but the server did not include it in its response.
Wann welchen verwenden
For 1001 (Going Away): Implement automatic reconnection logic with exponential backoff in your client. If the server is restarting, the client should retry after a short delay. For 1010 (Mandatory Extension): Enable the required extension on the server, or update the client to make the extension optional. Check the Sec-WebSocket-Extensions header in the handshake response.