Skip to content

Close status is not optional? #61

@rotu

Description

@rotu

What is the issue with the WebSockets Standard?

This spec says that the close code is optional, in self-acknowledged contradiction1 of RFC 6455. The RFC is very explicit about this:

If this Close control frame contains no status code, The WebSocket Connection Close Code is considered to be 1005.

For instance, with Chrome and Node.JS using the popular ws package, closing a connection from the client with .close() results in CloseEvent with code 1005. On the other hand, closing the connection from the client with .close(1000) results in a CloseEvent with code 1000.

The MDN page has another take, suggesting that .close() is synonymous with .close(1000):

If unspecified, a close code for the connection is automatically set: to 1000 for a normal closure


From an end-user perspective, I think the behavior documented on MDN page makes the most sense (even though it aligns with neither standard. Calling the .close() function without an error indicates a normal, intended closure.

Footnotes

  1. @ricea, what was the erratum that you wished to make?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions