Back to error codes
ERROR 1006
WebSocket Abnormal Closure (Code 1006)
REST API Error
The WebSocket connection was closed abnormally without a proper closing handshake.
Root Cause
Network interruption, server crash, proxy timeout, or the server closed the connection without sending a close frame.
How to Fix
Implement automatic reconnection with exponential backoff. Handle the close event and reconnect after a delay.
Quick Summary
WebSocket close code 1006 means abnormal closure, no close frame was sent. Implement automatic reconnection with exponential backoff. Common with proxies that have connection timeouts.
Key Takeaways
Key Takeaways
- Code 1006 = abnormal closure (no close frame)
- Implement reconnection: on close, wait and reconnect with exponential backoff
- Proxies often close idle WebSocket connections, implement heartbeat/ping-pong
- Code 1000 = normal closure; 1001 = going away; 1006 = abnormal
Use Cases
When to use it
- Network interruption
- Server crashed
- Proxy timeout on idle connection
Watch out
Common Mistakes
- Not implementing reconnection logic, WebSocket connections drop and must be re-established
- Not implementing heartbeat, proxies close idle connections after a timeout
FAQ
1006 WebSocket Abnormal Closure (Code 1006), Frequently Asked
How do I implement WebSocket heartbeat?
Send a ping message every 30 seconds. If no pong is received within 5 seconds, close and reconnect.
Still having issues?
Check your network logs or use our developer tools to inspect headers, decode tokens, or validate your requests.