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 3bd885ad8b88c146a466d1ac6494304032aff429 (relevant discussion: #48).
When using
SSLSocket
,recv()
andsend()
may raiseSSLWantReadError
orSSLWantWriteError
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 forSSLWantReadError
andSSLWantWriteError
to do just that.Note: there is also some mention about calling
SSLSocket.recv()
to drain potentially available data before blocking onselect()
, but it seems like this is already covered by 3bd885ad8b88c146a466d1ac6494304032aff429 (relevant discussion: #48).This would also fix #87.