This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
In some cases, the WebSocket server could decide to close the connection with the client due to a WS subprotocol violation in a message sent from the client to server. In such a case, the WS server could send a WS close frame with some custom status code (i.e. >= 4000) and some reason text. Both status code and reason are optional as per WebSocket specification. When this occurs, it would be nice that the WebSocket stack in the client calls onclose() WS API function by passing both the status code and the reason (if present), so the function definition would become: function onclose(status, reason) In case of abrupt TCP disconnection or in case a WS close frame with no status/reason was received, both status and reason arguments would have _null_ value. This would be useful to notify the client the reason of the disconnection from the server. The WebSocket subprotocol could define some own custom WS close status codes (>= 4000). But this would be also useful for determining core WS protocol errors (such those defined by status code 1XXX).
I'm sorry, I missed that it's already defined in the WS API: http://dev.w3.org/html5/websockets/#event-definitions