WebSocket

WebSocket 1000 Normal Closure vs 1009 Message Too Big

Both WebSocket 1000 (Normal Closure) and 1009 (Message Too Big) belong to the WebSocket Close Codes category. 1000 indicates that the connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete. 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

The connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete.

Quando você o vê

The WebSocket connection closed gracefully after both sides finished exchanging data. This is the expected close code for a successful session.

Como corrigir

No fix needed — this indicates everything worked as intended. If you did not expect the connection to close, check your application logic for premature close() calls.

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

1.

WebSocket 1000: The connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete.

2.

WebSocket 1009: An endpoint is terminating the connection because it received a message that is too large for it to process.

3.

You encounter 1000 when the WebSocket connection closed gracefully after both sides finished exchanging data. This is the expected close code for a successful session.

4.

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 1000 (Normal Closure): No fix needed — this indicates everything worked as intended. If you did not expect the connection to close, check your application logic for premature close() calls. 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.

Saiba mais