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.

Description

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

Quand vous le voyez

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.

Comment résoudre

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

Description

An endpoint received a type of data it cannot accept. For example, a text-only endpoint received a binary message, or vice versa.

Quand vous le voyez

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.

Comment résoudre

Verify the message type (text vs binary) matches what the server expects. Update your client to send the correct opcode for the data format.

Différences clés

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.

Quand utiliser lequel

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.

En savoir plus