WebSocket

WebSocket 1002 Protocol Error vs 1005 No Status Received

Both WebSocket 1002 (Protocol Error) and 1005 (No Status Received) 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, 1005 means that a reserved value that indicates no status code was present in the Close frame. This code must not be set by an endpoint when sending a Close frame.

विवरण

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.

विवरण

A reserved value that indicates no status code was present in the Close frame. This code must not be set by an endpoint when sending a Close frame.

जब आप इसे देखें

The peer closed the connection with a Close frame that contained no status code payload. Your WebSocket library surfaces 1005 as a sentinel to indicate the absence of a code.

कैसे ठीक करें

This is an internal indicator, not a wire protocol value. If you see it frequently, the remote peer may have a bug where it sends empty Close frames — check the peer's implementation.

मुख्य अंतर

1.

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

2.

WebSocket 1005: A reserved value that indicates no status code was present in the Close frame. This code must not be set by an endpoint when sending a Close frame.

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 1005 when the peer closed the connection with a Close frame that contained no status code payload. Your WebSocket library surfaces 1005 as a sentinel to indicate the absence of a code.

कब किसका उपयोग करें

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 1005 (No Status Received): This is an internal indicator, not a wire protocol value. If you see it frequently, the remote peer may have a bug where it sends empty Close frames — check the peer's implementation.

और जानें