WebSocket

WebSocket 1000 Normal Closure vs 1010 Mandatory Extension

Both WebSocket 1000 (Normal Closure) and 1010 (Mandatory Extension) belong to the WebSocket Close Codes category. 1000 indicates that the connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete. 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.

Description

The connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete.

When You See It

The WebSocket connection closed gracefully after both sides finished exchanging data. This is the expected close code for a successful session.

How to Fix

No fix needed — this indicates everything worked as intended. If you did not expect the connection to close, check your application logic for premature close() calls.

Description

The client is terminating the connection because the server did not negotiate one or more expected extensions in the handshake response.

When You See It

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.

How to Fix

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.

Key Differences

1.

WebSocket 1000: The connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete.

2.

WebSocket 1010: The client is terminating the connection because the server did not negotiate one or more expected extensions in the handshake response.

3.

You encounter 1000 when the WebSocket connection closed gracefully after both sides finished exchanging data. This is the expected close code for a successful session.

4.

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.

When to Use Which

For 1000 (Normal Closure): No fix needed — this indicates everything worked as intended. If you did not expect the connection to close, check your application logic for premature close() calls. 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.

Learn More