You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been messing around with wsproto a bit, reading sources and writing sample code. (I sent a PR to update docs.) I am confused over the CLOSING and CLOSED states. I'm not sure if this is a bug or my own misunderstanding of the design.
Let's assume we have WSConnection instance called local and our peer has a WSConnection instance called remote. We call local.close() and wsproto sets the internal state to CLOSING and queues a close frame with code 1000 (normal closure). We call local.bytes_to_send() and then send that reply frame over the network.
On the peer, they receive our close frame and generate a ConnectionClosed event with code 1000. The peer's wsproto prepares a reply frame and the peer sends that back to us.
We call receive_bytes() and we get the peer's close reply, but this does not raise a ConnectionClosed event on our side, and the state is still CLOSING. Later, we call local.receive_bytes(None) and wsproto updates the internal state to CLOSED.
I have two questions about this:
Should wsproto enter the CLOSED state only after a close frame has been sent AND a close frame has been received? Why is receive_bytes() involved?
Should the side that initiates the closing handshake also get a ConnectionClosed event? This would make it easier to determine when the underlying connection needs to be torn down.
@mehaase I also had problems understanding the close behaviour, thats why I created #50 a while ago. Maybe you could look through my changes - hopefully they make sense to you, and are compliant with the RFC.
I need to read it more carefully and spend some time working with it, but I think #50 is a good idea.
The only hesitation I have is how to define "sending a close frame". If wsproto places a close frame in its outgoing buffer, is that good enough to consider it sent? I'm new to Sans-IO and not sure how to answer this question.
@Kriechi I read #50 a bit more carefully yesterday and wrote some sample code to try it out. I think it's exactly the right behavior. Unfortunately I am not a member of this organization, so I cannot expedite the review of your PRs. Is there anything else I could do to help out?
Activity
Kriechi commentedon Aug 21, 2018
@mehaase I also had problems understanding the close behaviour, thats why I created #50 a while ago. Maybe you could look through my changes - hopefully they make sense to you, and are compliant with the RFC.
mehaase commentedon Aug 21, 2018
I need to read it more carefully and spend some time working with it, but I think #50 is a good idea.
The only hesitation I have is how to define "sending a close frame". If wsproto places a close frame in its outgoing buffer, is that good enough to consider it sent? I'm new to Sans-IO and not sure how to answer this question.
mehaase commentedon Aug 23, 2018
@Kriechi I read #50 a bit more carefully yesterday and wrote some sample code to try it out. I think it's exactly the right behavior. Unfortunately I am not a member of this organization, so I cannot expedite the review of your PRs. Is there anything else I could do to help out?
Kriechi commentedon Aug 23, 2018
Thanks for checking!
I think leaving a comment on the PR should be enough to get some attention.
Kriechi commentedon Sep 6, 2018
Fixed by #50