This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 14180 - Call onclose() passing as argument the WS close frame status and status code and reason
Summary: Call onclose() passing as argument the WS close frame status and status code ...
Status: RESOLVED INVALID
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebSocket API (editor: Ian Hickson) (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-16 10:01 UTC by Iñaki Baz Castillo
Modified: 2011-09-16 11:44 UTC (History)
3 users (show)

See Also:


Attachments

Description Iñaki Baz Castillo 2011-09-16 10:01:40 UTC
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).
Comment 1 Iñaki Baz Castillo 2011-09-16 11:44:07 UTC
I'm sorry, I missed that it's already defined in the WS API:

http://dev.w3.org/html5/websockets/#event-definitions