-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Close status is not optional? #61
Comments
Section 7.1.2 says
It implies that I don't like MDN's interpretation, because it provides no way to send a Close frame with no body. I don't want to force someone to waste 2 bytes sending the code "1000" if the server doesn't care. |
The code is optional in the sense that, if omitted, the connection still gets closed. My reading is that it should be sent to indicate the client intended to close the connection (rather than, say, that the status was accidentally omitted or lost by an intermediary). I don’t think economizing on 2 bytes is a compelling reason. The server does care in that it is expected to behave differently and it does populate those two bytes in the response regardless. It’s notable that, while you can call So I guess the issue here (and what I hoped to glean from your erratum on RFC6455) is essentially that it’s unclear how code 1005 should be regarded:
|
Also, per this spec, if a |
Interesting. From your analysis, it looks like there was a difference of opinion between the people who designed the protocol and the people who designed the API. I don't have time to write an erratum, but if I did I would go for “the client does not use and does not care about the close code”, as I think it most closely describes real-world usage. If a developer went to the trouble to send code 1000, I would take it to mean that they might send some other code in other circumstances. |
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:
For instance, with Chrome and Node.JS using the popular
ws
package, closing a connection from the client with.close()
results inCloseEvent
with code 1005. On the other hand, closing the connection from the client with.close(1000)
results in aCloseEvent
with code 1000.The MDN page has another take, suggesting that
.close()
is synonymous with.close(1000)
: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
@ricea, what was the erratum that you wished to make? ↩
The text was updated successfully, but these errors were encountered: