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.

설명

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

이 코드를 보게 되는 경우

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.

해결 방법

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

설명

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

이 코드를 보게 되는 경우

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.

해결 방법

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

주요 차이점

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.

언제 어떤 것을 사용할지

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.

더 알아보기