WebSocket 1007 Invalid Payload Data vs 1009 Message Too Big
Both WebSocket 1007 (Invalid Payload Data) and 1009 (Message Too Big) belong to the WebSocket Close Codes category. 1007 indicates 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. Meanwhile, 1009 means that an endpoint is terminating the connection because it received a message that is too large for it to process.
Описание
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.
Описание
An endpoint is terminating the connection because it received a message that is too large for it to process.
Когда вы это видите
The message payload exceeded the server's configured maximum frame or message size limit. Common when uploading large files or sending huge JSON payloads over WebSocket.
Как исправить
Reduce the message size by chunking large payloads into smaller frames. Alternatively, increase the server's max message size configuration if the large payload is expected.
Ключевые различия
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.
WebSocket 1009: An endpoint is terminating the connection because it received a message that is too large for it to process.
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.
You encounter 1009 when the message payload exceeded the server's configured maximum frame or message size limit. Common when uploading large files or sending huge JSON payloads over WebSocket.
Когда что использовать
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. For 1009 (Message Too Big): Reduce the message size by chunking large payloads into smaller frames. Alternatively, increase the server's max message size configuration if the large payload is expected.