-
Notifications
You must be signed in to change notification settings - Fork 282
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
websocat does not properly perform the close handshake as defined in the RFC #269
Comments
I think without the With the |
Websocat expects close frame to be equivalent to EOF, i.e. you can send some request, followed by a close frame, then expect a reply, also followed by a close frame i.e. close frames are interpreted closer to More compliant behaviour may be implemented as a separate opt-in option (though probably more likely in Websocat4 branch instead of master). I don't really understand the reason why close frames are needed in Websockets in the first place (apart from providing additional message) and how they should interact with semi-closed ( Current Websocat4 behaviour is to interpret incoming close frames as EOF indicators and turn outgoing EOF indicators to close frames, with only pings having a special, direct patch from ingress to egress. There is a mechanism to close the whole socket (and its associated tasks) based on certain events, but currently reception of close frames is not connected to that mechanism. Activating it would probably just abandon all involved sockets abruptly, without a goodbye message (or only with a goodbye message in an uncongested case). |
Quickly implemented proper shutdown in When using
before the change and
After the change. It does not copy the close frame, but it does send it's own empty close frame. The change only affects the |
Why just this mode? |
Because non- But without Here is the table (built from my understanding, without actually checking all the cases):
|
We are working on a WebSocket server implementation. websocat is a really nice tool so far, however it violates the WebSocket specs:
In 5.5.1:
So when our server sends a close frame (with, lets say status code 4001) websocat does receive that close frame, but does not reply to it. So what happens now is that our server waits for the close reply, but since this never happens, the tcp connection stays open until our server times out and the connections eventually closes.
(BTW, I am aware of the
-E
option of websocat, which immediately shuts down the connection.)Using Wireshark, I can see the close frame gets send from the server to websocat, however websocat does not reply:
Calling the exact same webservice endpoint on our server with Firefox or Chrome, they correctly reply with an close frame (the "echo" with the same status code). After receiving this echoed close frame, our WebSocket server happily closes the underlying tcp connection immediately. Here is how that looks like in wireshark:
You can see the
[MASKED]
message (with the red arrow) is the reply from Firefox (or Chrome) to the WebSocket Server.Others also already are aware that websocat does not correctly handle the close handshake:
The text was updated successfully, but these errors were encountered: