WebSocket

WebSocket 1010 Mandatory Extension vs 1012 Service Restart

Both WebSocket 1010 (Mandatory Extension) and 1012 (Service Restart) belong to the WebSocket Close Codes category. 1010 indicates that the client is terminating the connection because the server did not negotiate one or more expected extensions in the handshake response. Meanwhile, 1012 means that the server is terminating the connection because it is restarting. The client should reconnect after a brief delay.

説明

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

このコードが表示される場合

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.

解決方法

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.

説明

The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.

このコードが表示される場合

The server is performing a planned restart — for example, during a deployment or configuration reload. The connection will be available again shortly.

解決方法

Implement automatic reconnection with a short delay (1-5 seconds). This code signals that reconnecting is expected and should succeed once the server is back up.

主な違い

1.

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

2.

WebSocket 1012: The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.

3.

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.

4.

You encounter 1012 when the server is performing a planned restart — for example, during a deployment or configuration reload. The connection will be available again shortly.

どちらをいつ使うか

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. For 1012 (Service Restart): Implement automatic reconnection with a short delay (1-5 seconds). This code signals that reconnecting is expected and should succeed once the server is back up.

詳しく見る