-
Notifications
You must be signed in to change notification settings - Fork 20
Description
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
1000for 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.