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.
Descrição
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.
Quando você o vê
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.
Como corrigir
Ensure text frames contain only valid UTF-8 encoded data. If you need to send raw bytes, use binary frames instead of text frames.
Descrição
An endpoint is terminating the connection because it received a message that is too large for it to process.
Quando você o vê
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.
Como corrigir
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.
Diferenças principais
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.
Quando usar qual
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.