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

Handle SSLWantReadError and SSLWantWriteErrors on recv and send. #100

Merged

Conversation

GeertL
Copy link
Contributor

@GeertL GeertL commented Mar 16, 2021

When using SSLSocket, recv() and send() may raise SSLWantReadError or SSLWantWriteError when the SSL socket is not yet ready to receive or send. In my experience, this tends to occur when e.g. sending large messages.

Currently, the SimpleWebSocketServer can't handle this and will drop the connection even though the connection is fine. Python docs recommend to catch these and retry after another call to select(). This PR adds try/except for SSLWantReadError and SSLWantWriteError to do just that.

Note: there is also some mention about calling SSLSocket.recv() to drain potentially available data before blocking on select(), but it seems like this is already covered by 3bd885a (relevant discussion: #48).

This would also fix #87.

@dpallot dpallot merged commit 5ee673a into dpallot:master Oct 21, 2022
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.

ssl.SSLWantReadError: The operation did not complete (read)
2 participants