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: Sometimes urllib2 raises URLError when trying POST with httpS
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, mrDoctorWho0.., r.david.murray
Priority: normal Keywords:

Created on 2013-09-20 10:55 by mrDoctorWho0.., last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
code.py mrDoctorWho0.., 2013-09-20 10:55 a part of code
Messages (3)
msg198141 - (view) Author: mrDoctorWho0 . (mrDoctorWho0..) Date: 2013-09-20 10:55
Trying to use POST-request to https://vk.com and sometimes library raise an error.
  File "library/vkApi.py", line 31, in post
    response = self.Opener.open(request)
  File "/usr/lib/python2.7/urllib2.py", line 404, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 422, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1222, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
    raise URLError(err)
URLError: <urlopen error _ssl.c:489: The handshake operation timed out>

This exception appears randomly, connection is ok 100%. I tried it on different machines with python 2.7.4 and 2.7.3.
msg198147 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-09-20 12:55
I would guess that if you did a network trace you'd find out there really was a packet that did not arrive (a timeout).  Note that detecting this is complicated by the fact that ssl is involved.  (I don't know the details, but I remember someone saying that more than one packet may be involved in something that looks like a single event at the OpenSSL level.)

It is certainly *possible* that there is a bug at the OpenSSL or (less likely) the _ssl module level, but the first step in debugging it would be to get that network trace, I think...

As I said, though, I'm not an expert in this area, perhaps someone who is will have other suggestions.
msg275199 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2016-09-08 22:46
I'm closing this ticket. It's old and hasn't seen any activity in almost three years.
History
Date User Action Args
2022-04-11 14:57:51adminsetgithub: 63257
2016-09-08 22:46:01christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg275199

resolution: not a bug
2013-09-20 12:55:52r.david.murraysetnosy: + r.david.murray
messages: + msg198147
2013-09-20 10:55:37mrDoctorWho0..create