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.