WebSocket 1000 Normal Closure vs 1015 TLS Handshake Failure
Both WebSocket 1000 (Normal Closure) and 1015 (TLS Handshake Failure) 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, 1015 means that a reserved value indicating the connection was closed because the TLS handshake failed. This code must not be set by an endpoint in a Close frame.
Descrição
The connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete.
Quando você o vê
The WebSocket connection closed gracefully after both sides finished exchanging data. This is the expected close code for a successful session.
Como corrigir
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.
Descrição
A reserved value indicating the connection was closed because the TLS handshake failed. This code must not be set by an endpoint in a Close frame.
Quando você o vê
The wss:// (WebSocket Secure) connection failed during the TLS negotiation — commonly due to an expired certificate, untrusted CA, or TLS version mismatch.
Como corrigir
Verify the server's TLS certificate is valid and not expired. Ensure both client and server support compatible TLS versions (TLS 1.2+). Check that intermediate certificates are properly chained.
Diferenças principais
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 1015: A reserved value indicating the connection was closed because the TLS handshake failed. This code must not be set by an endpoint in a Close frame.
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 1015 when the wss:// (WebSocket Secure) connection failed during the TLS negotiation — commonly due to an expired certificate, untrusted CA, or TLS version mismatch.
Quando usar qual
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 1015 (TLS Handshake Failure): Verify the server's TLS certificate is valid and not expired. Ensure both client and server support compatible TLS versions (TLS 1.2+). Check that intermediate certificates are properly chained.