This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Abnormal SSL timeouts when using socket timeouts - once again
Type: behavior Stage: resolved
Components: IO Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: arekm, georg.brandl, maltehelmert, pakal, pitrou, pristine777, tarek-ziade, twouters
Priority: normal Keywords:

Created on 2010-11-05 14:31 by pakal, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg120498 - (view) Author: Pascal Chambon (pakal) * Date: 2010-11-05 14:31
On freebsd 8, using python 2.6.6, I've run into the bug already widely dealt with in these reports :
http://bugs.python.org/issue1380952
http://bugs.python.org/issue1153016

When using socket timeouts (eg. with socket.setdefaulttimeout()), whatever the timeout I use (eg. 10 seconds), I begin having random "SSLError: The read operation timed out" exceptions in my http calls, via urlopen or 3rd party libraries.

Here is an example of traceback ending:

...
  File "/usr/local/lib/python2.6/site-packages/ZSI-2.0-py2.6.egg/ZSI/client.py", line 349, in ReceiveRaw
    response = self.h.getresponse()
  File "/usr/local/lib/python2.6/httplib.py", line 990, in getresponse
    response.begin()
  File "/usr/local/lib/python2.6/httplib.py", line 391, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python2.6/httplib.py", line 349, in _read_status
    line = self.fp.readline()
  File "/usr/local/lib/python2.6/socket.py", line 427, in readline
    data = recv(1)
  File "/usr/local/lib/python2.6/ssl.py", line 215, in recv
    return self.read(buflen)
  File "/usr/local/lib/python2.6/ssl.py", line 136, in read
    return self._sslobj.read(len)
SSLError: The read operation timed out

I've checked the py2.6.6 sources, the patches described in previous reports are still applied (eg. SSL_pending() checks etc.), I have no idea of how so long socket timeouts might interfere with ssl operations...
msg120500 - (view) Author: Malte Helmert (maltehelmert) Date: 2010-11-05 14:40
I checked if issue1153016 has reappeared for me (Ubuntu, Python 2.6.6), but it hasn't. Both the urllib and the imaplib examples given there work fine for me. Or at least opening the connections works fine for me, which it didn't at the time of issue1153016.

But you say you have random errors, so maybe I need to exercise this more heavily. Can you attach a test script that can be used to make the bug appear?
msg120503 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-11-05 14:53
> When using socket timeouts (eg. with socket.setdefaulttimeout()),
> whatever the timeout I use (eg. 10 seconds), I begin having random
> "SSLError: The read operation timed out" exceptions in my http calls,
> via urlopen or 3rd party libraries.

Well, this isn't a random error. It just signals that the timeout has expired. It's a pity that it raises SSLError rather than socket.timeout, though.

Or are you saying that the exception is raised too early? If so, it would be nice to have a way of reproducing.
msg120507 - (view) Author: Pascal Chambon (pakal) * Date: 2010-11-05 15:22
The exception is raised too early, none of my calls takes more than 1-2 seconds and I've a default timeout set at 10s or more.

This occurs rather rarely, one or two times on some hundreds of calls. I'll make a little script to try to isolate the pb.
msg120510 - (view) Author: Pascal Chambon (pakal) * Date: 2010-11-05 15:53
Humz on second thought you may be right, now I have some trouble reproducing the bugs (wich have been there since the beginning, though), so it may be that the webservice I call seldom takes 10+ seconds to answer (weird anyway).

I've placed timers in the codebase, the pb will eventually surface again.
msg120733 - (view) Author: Pascal Chambon (pakal) * Date: 2010-11-08 11:53
Allright, it actually looks more like a pathological latency behaviour of my target platforms than a ssl bug... 
I was mislead by the heavy history of socket.settimeout(), sorry. >_<
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54536
2010-11-08 19:09:10r.david.murraysetresolution: not a bug
stage: resolved
2010-11-08 11:53:45pakalsetstatus: open -> closed

messages: + msg120733
2010-11-05 15:53:38pakalsetmessages: + msg120510
2010-11-05 15:22:48pakalsetmessages: + msg120507
2010-11-05 14:53:06pitrousetnosy: + pitrou
messages: + msg120503
2010-11-05 14:40:46maltehelmertsetmessages: + msg120500
2010-11-05 14:31:47pakalcreate