WebSocket

WebSocket 1006 Abnormal Closure vs 1015 TLS Handshake Failure

Both WebSocket 1006 (Abnormal Closure) and 1015 (TLS Handshake Failure) belong to the WebSocket Close Codes category. 1006 indicates that a reserved value indicating the connection was closed abnormally without a Close frame being sent. This code must not be set by an endpoint. 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.

설명

A reserved value indicating the connection was closed abnormally without a Close frame being sent. This code must not be set by an endpoint.

이 코드를 보게 되는 경우

The TCP connection dropped unexpectedly — the server crashed, the network cable was unplugged, or a firewall killed the idle connection. No proper WebSocket Close handshake occurred.

해결 방법

Implement reconnection with exponential backoff. Use WebSocket ping/pong frames to detect dead connections early. Check for network-level timeouts or aggressive load balancer idle limits.

설명

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.

이 코드를 보게 되는 경우

The wss:// (WebSocket Secure) connection failed during the TLS negotiation — commonly due to an expired certificate, untrusted CA, or TLS version mismatch.

해결 방법

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.

주요 차이점

1.

WebSocket 1006: A reserved value indicating the connection was closed abnormally without a Close frame being sent. This code must not be set by an endpoint.

2.

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.

3.

You encounter 1006 when the TCP connection dropped unexpectedly — the server crashed, the network cable was unplugged, or a firewall killed the idle connection. No proper WebSocket Close handshake occurred.

4.

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.

언제 어떤 것을 사용할지

For 1006 (Abnormal Closure): Implement reconnection with exponential backoff. Use WebSocket ping/pong frames to detect dead connections early. Check for network-level timeouts or aggressive load balancer idle limits. 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.

더 알아보기