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

example client: cancel command loop on close of connection #52

Closed
wants to merge 1 commit into from

Conversation

belm0
Copy link
Member

@belm0 belm0 commented Oct 12, 2018

Intended to fix #22.

It does handle the connection close cases fine. However it somehow breaks normal communication. Before this change, here is server-side log from "send foo":

DEBUG:trio-websocket:conn#1 received 9 bytes
DEBUG:trio-websocket:conn#1 received event: TextReceived
DEBUG:trio-websocket:conn#1 sending 5 bytes

With this change, the server gets the bytes but appears to not recognize the end of the message, so never reponds:

DEBUG:trio-websocket:conn#2 received 9 bytes

@njsmith
Copy link
Member

njsmith commented Oct 13, 2018

It looks like you're starting handle_connection in the background, and then immediately closing the connection and cancelling it?

@belm0
Copy link
Member Author

belm0 commented Oct 13, 2018

Yes, thank you-- this confusion resulted from observed behavior of open_websocket_url context manager hanging when I was using an older wsproto.

@belm0 belm0 closed this Oct 13, 2018
@belm0 belm0 deleted the example_client_shutdown branch October 13, 2018 07:07
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.

client example not handling closed connection
2 participants