WebSocket 1011 Internal Error vs 1012 Service Restart
Both WebSocket 1011 (Internal Error) and 1012 (Service Restart) belong to the WebSocket Close Codes category. 1011 indicates that the server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request. Meanwhile, 1012 means that the server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
説明
The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.
このコードが表示される場合
The server hit an unhandled exception or crashed while processing a WebSocket message. This is the WebSocket equivalent of HTTP 500 Internal Server Error.
解決方法
Check the server-side application logs for stack traces and exceptions. Fix the underlying bug that caused the crash and add proper error handling around message processing.
説明
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 1011: The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.
WebSocket 1012: The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
You encounter 1011 when the server hit an unhandled exception or crashed while processing a WebSocket message. This is the WebSocket equivalent of HTTP 500 Internal Server Error.
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 1011 (Internal Error): Check the server-side application logs for stack traces and exceptions. Fix the underlying bug that caused the crash and add proper error handling around message processing. 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.