WebSocket

WebSocket 1002 Protocol Error vs 1014 Bad Gateway

Both WebSocket 1002 (Protocol Error) and 1014 (Bad Gateway) 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, 1014 means that the server acting as a gateway or proxy received an invalid response from an upstream server it accessed while attempting to fulfill the request.

Описание

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.

Описание

The server acting as a gateway or proxy received an invalid response from an upstream server it accessed while attempting to fulfill the request.

Когда вы это видите

A reverse proxy or API gateway tried to establish a WebSocket connection to a backend server but received an invalid or no response. The upstream server may be down or misconfigured.

Как исправить

Check the health of the upstream/backend WebSocket server. Verify the proxy configuration routes WebSocket upgrade requests correctly and that the backend is listening on the expected port.

Ключевые различия

1.

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

2.

WebSocket 1014: The server acting as a gateway or proxy received an invalid response from an upstream server it accessed while attempting to fulfill the request.

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 1014 when a reverse proxy or API gateway tried to establish a WebSocket connection to a backend server but received an invalid or no response. The upstream server may be down or misconfigured.

Когда что использовать

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 1014 (Bad Gateway): Check the health of the upstream/backend WebSocket server. Verify the proxy configuration routes WebSocket upgrade requests correctly and that the backend is listening on the expected port.

Узнать больше