-
Notifications
You must be signed in to change notification settings - Fork 316
Properly implement Close Handshake #109
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
Comments
See https://circleci.com/gh/nhooyr/websocket/16?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-checks-link for a test failure that reproduces this. That test expected an error that indicates the remote WebSocket status frame but instead it got a write failure error out because the remote end closed the connection right after sending the close frame. This is also reproducible with gorilla/websocket and I'm sure a host of other libraries. |
My WIP branch is at https://github.com/nhooyr/websocket/tree/close-handshake |
Nvm, can't reproduce with gorilla/websocket as it returns the CloseError regardless of whether or not the close frame write succeeded. Maybe we ought to do this too as there is no issue on gorilla/websocket about this and it is much simpler a solution. |
Even if gorilla/websocket gets it right, other WebSocket libraries might not so I will need to survey them. |
I say we just keep it simple for now, if it ends up being an issue, I'll keep that branch so we can refer to it and easily implement it. |
See #103
So the problem here is not really that the close handshake is useful but that a lot of libraries expect to be able to reply to a close frame with a echoed close frame and if the connection is closed before they can reply, they error out and it is confusing.
So I'm going to revive my effort in #104 to read the connection automatically in Close() and discard all messages until a Close frame is received for 5s.
This should also go into the README as a nice behavioural advantage over gorilla/websocket and gobwas/ws.
The text was updated successfully, but these errors were encountered: