-
Notifications
You must be signed in to change notification settings - Fork 226
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
Protocol errors should send a close frame and shutdown the connection #38
Comments
This effectively means that the caller must drop |
I was thinking that the |
It doesn't, it just reports an error to you. A natural user's reaction to an error is dropping a connection. Probably I should initiate CLOSING earlier. |
Sorry for the confusion - what I mean in the previous comment is what I think should happen in case one of the conditions occur. I think that when an unrecoverable error occurs, the WebSocket should transition to CLOSING and all furthers operations on the WebSocket should fail immediately (when doing anything). This is how the |
Thank you, will be implemented. |
I don't understand what would make it "natural", but it sure would save users a lot of time if this assumption would be documented. Note that dropping the connection and doing a close handshake are mutually exclusive, because if the other end is trying to acknowledge the close frame, they will get ConnectionReset if it's dropped. |
Port to tokio reform
The RFC defines a "Fail the WebSocket Connection" procedure:
Grepping the RFC for "Fail the WebSocket Connection" brings up the following cases:
If a nonzero value [for
RSV1-3
] is received and none of the negotiated extensions defines the meaning of such a nonzero valueIf an unknown opcode is received
When an endpoint is to interpret a byte stream as UTF-8 but finds that the byte stream is not, in fact, a valid UTF-8 stream
I've ignored errors in the handshake phase since these should be naturally handled correctly I think.
Currently tungstenite does not follow the RFC; when one of these conditions happen the error is propagated to the caller but the
WebSocket
is still usable. Beyond just conformance I think making these errors unrecoverable makes sense, since something is obviously wrong. Continuing like nothing happened may turn up garbage.The text was updated successfully, but these errors were encountered: