WebSocket 1003 Unsupported Data vs 1006 Abnormal Closure
Both WebSocket 1003 (Unsupported Data) and 1006 (Abnormal Closure) belong to the WebSocket Close Codes category. 1003 indicates that an endpoint received a type of data it cannot accept. For example, a text-only endpoint received a binary message, or vice versa. Meanwhile, 1006 means 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.
Descripción
An endpoint received a type of data it cannot accept. For example, a text-only endpoint received a binary message, or vice versa.
Cuándo lo verás
The client sent a binary frame to a server that only handles text, or a text frame to a binary-only endpoint. The receiver does not know how to process this data type.
Cómo solucionarlo
Verify the message type (text vs binary) matches what the server expects. Update your client to send the correct opcode for the data format.
Descripción
A reserved value indicating the connection was closed abnormally without a Close frame being sent. This code must not be set by an endpoint.
Cuándo lo verás
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.
Cómo solucionarlo
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.
Diferencias clave
WebSocket 1003: An endpoint received a type of data it cannot accept. For example, a text-only endpoint received a binary message, or vice versa.
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.
You encounter 1003 when the client sent a binary frame to a server that only handles text, or a text frame to a binary-only endpoint. The receiver does not know how to process this data type.
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.
Cuándo usar cada uno
For 1003 (Unsupported Data): Verify the message type (text vs binary) matches what the server expects. Update your client to send the correct opcode for the data format. 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.