Skip to content

The right way to close a connection. #444

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

Closed
yjqiang opened this issue Jul 20, 2018 · 2 comments
Closed

The right way to close a connection. #444

yjqiang opened this issue Jul 20, 2018 · 2 comments

Comments

@yjqiang
Copy link

yjqiang commented Jul 20, 2018

I create a websocket connection by using "websockets.connect()", but maybe the connection is broken or other things wrong, so I have to close it and then reconnect. I think https://websockets.readthedocs.io/en/stable/api.html#websockets.protocol.WebSocketCommonProtocol.close is what I want. Am I right?
And I noticed one thing which makes me confused, "It’s safe to wrap this coroutine in ensure_future() since errors during connection termination aren’t particularly useful.", Why? I don't understand it.

@yjqiang
Copy link
Author

yjqiang commented Jul 24, 2018

And if I close the client by hands but receive pool on the client still have some data to read (but I don't need to handle it and I just want to ignore the data). Is it safe?

@aaugustin
Copy link
Member

Yes, it's safe to close connections, unread data will be discarded.

An option to reconnect automatically was requested in #414, so I'm going to close this issue as a duplicate.

@aaugustin aaugustin mentioned this issue Jun 23, 2019
18 tasks
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

No branches or pull requests

2 participants