WantReadError when using ws4py over SSL [updated on 28.11 with details]
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- networking
Research direction
Start with droid_cherrypy_server.py and websocket.py's once() method around the recv call at line 380. Reproduce the SSL case using repeated 500-character messages and a large first message, then trace how pyOpenSSL's WantReadError is surfaced. The issue is resolved when these messages are received without repeated errors or silently ignoring the exception.
Written by the indexing model from the issue text.
Description
Hello,
I started from the droid_cherrypy_server.py example, and I am using SSL.
For some reason, the server goes into WantReadError.
The issue appears only with Websocket over SSL.
----- UPDATE (28.11.2016)
To summarize:
WANT_READ_ERROR appears when:
- 4th-5th message in a row in sent (sending data to the server from the phone with a medium size (the size of 500 character string) repeatedly over short intervals (1 second)),
- A large message is sent for the first time (from the phone to the server).
THE SPECIFIC ERROR STACK TRACE (on the server running droid.py) LOOKS LIKE THIS (at the moment when the large message is sent / or subsequent message is sent in a row):
(IP_ADDR2)- - [26/Oct/2016:16:05:09] "GET /ws HTTP/1.1" 101 - "" ""
[2016-10-26 16:05:09,065] INFO Managing websocket [Local => (IP IP_ADDR1):65006 | Remote => (IP_ADDR2):56645]
[2016-10-26 16:05:27,719] ERROR Failed to receive data
Traceback (most recent call last):
File "/home/myusername/virtualenv/lawouach/local/lib/python2.7/site-packages/ws4py/websocket.py", line 380, in once
b = self.sock.recv(self.reading_buffer_size)
File "build/bdist.linux-x86_64/egg/OpenSSL/SSL.py", line 1304, in recv
self._raise_ssl_error(self._ssl, result)
File "build/bdist.linux-x86_64/egg/OpenSSL/SSL.py", line 1149, in _raise_ssl_error
raise WantReadError()
WantReadError
ATTEMPT 1 (failed):
- Changing default_buffer_size to something very high like 100000
It did not help (not sure if this change even made sense but I supposed it has to do with the buffer).
ATTEMPT 2 (semi-successful):
I updated the code for websocket.py to simply let the OpenSSLError pass:
def once:
except (socket.error, OSError) as e:
self.unhandled_error(e)
return False
except (pyOpenSSLError) as e:
pass
With this code, everything works fine (the messages are received and read by the server).
However, this is an ugly solution as the issue persists: the error is thrown a couple of times before the message is actually read (cherrypy.log in the except (pyOpenSSLError) indicates a series of errors thrown before the message is finally read).
Does anyone have an idea what is happening and how it resolved or could you please at least point me in the right direction?
Thank you in advance.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 285
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Lawouach/WebSocket-for-Python
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Lawouach/WebSocket-for-Python#300 ·
-
question
Lawouach/WebSocket-for-Python#297 · 2 comments · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
Lawouach/WebSocket-for-Python#296 ·
-
Lawouach/WebSocket-for-Python#280 · 1 comment · 1 assignee ·
-
Setup new CI Open
Lawouach/WebSocket-for-Python#275 · 1 assignee ·
All issues in Lawouach/WebSocket-for-Python
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100