WebSocket 1012 Service Restart vs 1015 TLS Handshake Failure
Both WebSocket 1012 (Service Restart) and 1015 (TLS Handshake Failure) belong to the WebSocket Close Codes category. 1012 indicates that the server is terminating the connection because it is restarting. The client should reconnect after a brief delay. Meanwhile, 1015 means that a reserved value indicating the connection was closed because the TLS handshake failed. This code must not be set by an endpoint in a Close frame.
描述
The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
何时出现
The server is performing a planned restart — for example, during a deployment or configuration reload. The connection will be available again shortly.
如何修复
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.
描述
A reserved value indicating the connection was closed because the TLS handshake failed. This code must not be set by an endpoint in a Close frame.
何时出现
The wss:// (WebSocket Secure) connection failed during the TLS negotiation — commonly due to an expired certificate, untrusted CA, or TLS version mismatch.
如何修复
Verify the server's TLS certificate is valid and not expired. Ensure both client and server support compatible TLS versions (TLS 1.2+). Check that intermediate certificates are properly chained.
主要区别
WebSocket 1012: The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
WebSocket 1015: A reserved value indicating the connection was closed because the TLS handshake failed. This code must not be set by an endpoint in a Close frame.
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.
You encounter 1015 when the wss:// (WebSocket Secure) connection failed during the TLS negotiation — commonly due to an expired certificate, untrusted CA, or TLS version mismatch.
何时使用哪个
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. For 1015 (TLS Handshake Failure): Verify the server's TLS certificate is valid and not expired. Ensure both client and server support compatible TLS versions (TLS 1.2+). Check that intermediate certificates are properly chained.