WebSocket

WebSocket 1003 Unsupported Data vs 1014 Bad Gateway

Both WebSocket 1003 (Unsupported Data) and 1014 (Bad Gateway) belong to the WebSocket Close Codes category. 1003 indicates that an endpoint received a type of data it cannot accept. For example, a text-only endpoint received a binary message, or vice versa. 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.

Mô tả

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

Khi bạn thấy mã này

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ách khắc phục

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

Mô tả

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

Khi bạn thấy mã này

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.

Cách khắc phục

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.

Sự khác biệt chính

1.

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.

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 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.

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.

Khi nào dùng cái nào

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. 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.

Tìm hiểu thêm