WebSocket

WebSocket 1002 Protocol Error vs 1003 Unsupported Data

Both WebSocket 1002 (Protocol Error) and 1003 (Unsupported Data) belong to the WebSocket Close Codes category. 1002 indicates that an endpoint is terminating the connection because it received data that violates the WebSocket protocol specification. Meanwhile, 1003 means that an endpoint received a type of data it cannot accept. For example, a text-only endpoint received a binary message, or vice versa.

Descripción

An endpoint is terminating the connection because it received data that violates the WebSocket protocol specification.

Cuándo lo verás

The WebSocket frame format is invalid — a malformed header, incorrect masking, or a reserved opcode was used. This usually indicates a broken client or proxy.

Cómo solucionarlo

Check that both client and server strictly follow RFC 6455 framing rules. Inspect intermediary proxies that may be corrupting WebSocket frames.

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.

Diferencias clave

1.

WebSocket 1002: An endpoint is terminating the connection because it received data that violates the WebSocket protocol specification.

2.

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.

3.

You encounter 1002 when the WebSocket frame format is invalid — a malformed header, incorrect masking, or a reserved opcode was used. This usually indicates a broken client or proxy.

4.

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.

Cuándo usar cada uno

For 1002 (Protocol Error): Check that both client and server strictly follow RFC 6455 framing rules. Inspect intermediary proxies that may be corrupting WebSocket frames. 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.

Saber más