1006
communication
connection_error
ai_generated
partial
WebSocket close frame received with status code 1006 (abnormal closure)
ID: communication/websocket-1006-abnormal-closure
70%Fix Rate
82%Confidence
1Evidence
2024-01-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| RFC 6455 | active | — | — | — |
| WebSocket++ 0.8.2 | active | — | — | — |
| ws 8.16 | active | — | — | — |
| Node.js 20 | active | — | — | — |
Root Cause
WebSocket connection terminated unexpectedly without a close frame, typically due to network failure, proxy timeout, or server crash.
generic中文
WebSocket连接在没有关闭帧的情况下意外终止,通常由网络故障、代理超时或服务器崩溃引起。
Official Documentation
https://datatracker.ietf.org/doc/html/rfc6455#section-7.4.1Workarounds
-
80% success Implement automatic reconnection with exponential backoff on the client. When a 1006 closure is detected, wait 1s, 2s, 4s, etc., before reconnecting. Log the event to diagnose network stability.
Implement automatic reconnection with exponential backoff on the client. When a 1006 closure is detected, wait 1s, 2s, 4s, etc., before reconnecting. Log the event to diagnose network stability.
-
75% success Check proxy and load balancer settings for WebSocket timeout. On NGINX, ensure proxy_read_timeout is set high (e.g., 3600s) and proxy_http_version is 1.1 with Connection upgrade.
Check proxy and load balancer settings for WebSocket timeout. On NGINX, ensure proxy_read_timeout is set high (e.g., 3600s) and proxy_http_version is 1.1 with Connection upgrade.
中文步骤
Implement automatic reconnection with exponential backoff on the client. When a 1006 closure is detected, wait 1s, 2s, 4s, etc., before reconnecting. Log the event to diagnose network stability.
Check proxy and load balancer settings for WebSocket timeout. On NGINX, ensure proxy_read_timeout is set high (e.g., 3600s) and proxy_http_version is 1.1 with Connection upgrade.
Dead Ends
Common approaches that don't work:
-
Increase the WebSocket ping/pong interval on the client
70% fail
1006 is not a timeout error; it's an abnormal closure where no close frame is sent. Ping/pong intervals only help with idle timeouts, not sudden disconnections
-
Disable SSL/TLS on the WebSocket connection
85% fail
1006 can occur over both ws:// and wss://; disabling encryption does not prevent network-level drops
-
Switch from WebSocket to long polling as a workaround
90% fail
Long polling introduces different failure modes and does not fix the root cause of unstable WebSocket connections