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.
주요 차이점
WebSocket 1010: The client is terminating the connection because the server did not negotiate one or more expected extensions in the handshake response.
WebSocket 1012: The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
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.
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.