Skip to content

make close-handshake more explicit - #50

Merged
Kriechi merged 1 commit into
python-hyper:masterfrom
Kriechi:close-handshake-behaviour
Sep 6, 2018
Merged

Kriechi merged 1 commit into
python-hyper:masterfrom
Kriechi:close-handshake-behaviour

Conversation

@Kriechi

@Kriechi Kriechi commented Aug 19, 2017

Copy link
Copy Markdown
Member

No description provided.

@Kriechi
Kriechi force-pushed the close-handshake-behaviour branch from 7ec8b61 to 75f4f02 Compare August 19, 2017 19:42
@Lukasa

Lukasa commented Aug 19, 2017

Copy link
Copy Markdown
Member

@jeamland Again, I think this is reasonable, but I'd like you to take a look at it as you're more familiar with websockets than I.

@njsmith

njsmith commented Nov 11, 2017

Copy link
Copy Markdown
Member

It's not really clear to me what this change is trying to do -- can you elaborate?

@Kriechi

Kriechi commented Nov 12, 2017 •

Copy link
Copy Markdown
Member Author

Sorry, this PR is a few months old - this is what I remember:

When working on wsproto support in mitmproxy (mitmproxy/mitmproxy#2545) we experienced odd behaviour during the closing handshake, i.e., the final "CLOSE" frame was not sent/received.
ref https://tools.ietf.org/html/rfc6455#section-1.4

This PR tries to make the closing-handshake state change more explicit:
After the other endpoint sends a close frame, we have to reply with a close frame. This means this frame must also be received on the other end before the socket can be closed for real.
I added a test which checks for the correct state changes and received / sent frames.

@Kriechi
Kriechi force-pushed the close-handshake-behaviour branch from 75f4f02 to 043a6e1 Compare June 10, 2018 12:39
@Kriechi

Kriechi commented Jun 10, 2018

Copy link
Copy Markdown
Member Author

@njsmith care to take another look?
The most important bit here is https://github.com/python-hyper/wsproto/pull/50/files#diff-c1e7881f91e3084e60df36b88fe06842R45.
Previously wsproto did not complete the two-way close handshake, due to entering the CLOSED state too early. Now it is documented properly that the final CLOSE frame is emitted and needs to be sent to the other endpoint.

@Kriechi Kriechi mentioned this pull request Aug 13, 2018
@mehaase

mehaase commented Aug 23, 2018

Copy link
Copy Markdown
Member

This PR directly addresses the point of confusion that I raised in #64. It's a small patch that makes the closing behavior more intuitive. I am working on a Trio WebSocket library, and this behavior is more convenient and simplifies my implementation.

I'm not a member of python-hyper, but as an unofficial reviewer I give this patch two thumbs up. 👍 👍

@m-u-xyz

m-u-xyz commented Sep 5, 2018

Copy link
Copy Markdown

Please merge this PR. It makes sense (eminently so) and simplifies using the library, as it allows me to separate "normal closing" and "abnormal connection loss" handling much more cleanly.

@njsmith

njsmith commented Sep 5, 2018

Copy link
Copy Markdown
Member

@mehaase @smurfix As you've no doubt noticed, wsproto is rather unmaintained right now... would either or both of you be interested in becoming maintainers? (I'm not sure whether I have the authority to just grant that unilaterally, but I'm pretty sure @jeamland and @Lukasa won't have any objections.)

@Kriechi

Kriechi commented Sep 5, 2018

Copy link
Copy Markdown
Member Author

@njsmith I'm one of the @mitmproxy devs and we rely on wsproto and hyper-h2 for our protocol stack.

So I'm pretty interested in keeping this project alive! I'm already part of the Contributor python-hyper organization. I would be happy to take over responsibilities - including pushing out new releases!

@m-u-xyz

m-u-xyz commented Sep 5, 2018

Copy link
Copy Markdown

I'd recommend adding @Kriechi and/or @mehaase; my time is spread fairly thinly already, so I'm reluctant to add yet another project to the iist.

@mehaase

mehaase commented Sep 5, 2018

Copy link
Copy Markdown
Member

I am happy to join the project. I can help out as a reviewer since that seems to be a bottleneck.

@Kriechi
Kriechi merged commit 5554c5e into python-hyper:master Sep 6, 2018
@Kriechi
Kriechi deleted the close-handshake-behaviour branch September 6, 2018 12:55
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.

5 participants