Skip to content
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

a whole websoceket connection when close #1722

Closed
wants to merge 4 commits into from

Conversation

alawn-wang
Copy link
Contributor

fixes #
A whole websocket connection should send a close frame when received a close frame.
This is a standard in RFC6455 chapter 5.5.1.https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.1

@alawn-wang alawn-wang closed this Dec 14, 2023
@alawn-wang alawn-wang reopened this Dec 14, 2023
Copy link
Contributor

@gdamore gdamore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is quite correct. Because otherwise we would get into a ping pong loop of close frames. But yes the code as it stands does not conform to the RFC.

I will look more closely to verify whether my concern is correct.

@alawn-wang
Copy link
Contributor Author

Ok, I know what you mean. If it's closed normally, it won't have this problem. Because when it first received the close-frame, the 'ws->close' will be change as 'true' in 'ws_send_close()'. when you second received the close frame again, it won't send close-frame again.

@gdamore
Copy link
Contributor

gdamore commented Dec 15, 2023

I've gone back and looked and I'm still concerned, although it's different now.

My specific concern here is that it is possible for the TCP connection to be left dangling. The logic I had before was to send the close, and really we should linger for that, and then close the session entirely. It looks to me like instead the existing code was waiting for the received reply. Which is wrong too.

The logic needs to be changed as thus (pseudo code):

rx callback: if frame is close, then
if already sent close, its a reply, just close the socket
else send close, with timeout

tx callback: if frame is close, then
if already received close, then just close socket
else wait for receive close, with timeout

if timeout (either send or recv) fires, just close the socket.

If I get some time this weekend I'll see if I can put that together.

Copy link
Contributor

@gdamore gdamore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will almost certainly leave dangling TCP connections. Please see my other comments.

@gdamore
Copy link
Contributor

gdamore commented Dec 15, 2023

I do btw recall deciding it was ok to break from the specification on this item, but now I think that was misguided. We should implement the spec properly.

@gdamore
Copy link
Contributor

gdamore commented Dec 18, 2023

I've fixed this entirely. I'm declining this PR as a result.

@gdamore gdamore closed this Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants