WebSocket 1003 Unsupported Data vs 1007 Invalid Payload Data
Both WebSocket 1003 (Unsupported Data) and 1007 (Invalid Payload Data) 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, 1007 means that an endpoint received a message with payload data that is inconsistent with the message type. For example, a text message contained non-UTF-8 data.
Описание
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.
Описание
An endpoint received a message with payload data that is inconsistent with the message type. For example, a text message contained non-UTF-8 data.
Когда вы это видите
A text frame was received but its payload is not valid UTF-8. This commonly happens when binary data is accidentally sent as a text frame.
Как исправить
Ensure text frames contain only valid UTF-8 encoded data. If you need to send raw bytes, use binary frames instead of text frames.
Ключевые различия
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.
WebSocket 1007: An endpoint received a message with payload data that is inconsistent with the message type. For example, a text message contained non-UTF-8 data.
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.
You encounter 1007 when a text frame was received but its payload is not valid UTF-8. This commonly happens when binary data is accidentally sent as a text frame.
Когда что использовать
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 1007 (Invalid Payload Data): Ensure text frames contain only valid UTF-8 encoded data. If you need to send raw bytes, use binary frames instead of text frames.