WebSocket 1000 Normal Closure vs 1012 Service Restart
Both WebSocket 1000 (Normal Closure) and 1012 (Service Restart) 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, 1012 means that the server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
Açıklama
The connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete.
Gördüğünüzde
The WebSocket connection closed gracefully after both sides finished exchanging data. This is the expected close code for a successful session.
Nasıl Düzeltilir
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.
Açıklama
The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
Gördüğünüzde
The server is performing a planned restart — for example, during a deployment or configuration reload. The connection will be available again shortly.
Nasıl Düzeltilir
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.
Temel Farklar
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.
WebSocket 1012: The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
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.
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.
Hangisini Ne Zaman Kullanmalı
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 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.