WebSocket 1009 Message Too Big vs 1012 Service Restart
Both WebSocket 1009 (Message Too Big) and 1012 (Service Restart) belong to the WebSocket Close Codes category. 1009 indicates that an endpoint is terminating the connection because it received a message that is too large for it to process. Meanwhile, 1012 means that the server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
Mô tả
An endpoint is terminating the connection because it received a message that is too large for it to process.
Khi bạn thấy mã này
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.
Cách khắc phục
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.
Mô tả
The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
Khi bạn thấy mã này
The server is performing a planned restart — for example, during a deployment or configuration reload. The connection will be available again shortly.
Cách khắc phục
Implement automatic reconnection with a short delay (1-5 seconds). This code signals that reconnecting is expected and should succeed once the server is back up.
Sự khác biệt chính
WebSocket 1009: An endpoint is terminating the connection because it received a message that is too large for it to process.
WebSocket 1012: The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
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.
You encounter 1012 when the server is performing a planned restart — for example, during a deployment or configuration reload. The connection will be available again shortly.
Khi nào dùng cái nào
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. For 1012 (Service Restart): Implement automatic reconnection with a short delay (1-5 seconds). This code signals that reconnecting is expected and should succeed once the server is back up.