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: do_handshake stuck in ssl.py
Type: behavior Stage: resolved
Components: SSL Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: christian.heimes, david987
Priority: normal Keywords:

Created on 2018-08-20 03:25 by david987, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg323775 - (view) Author: David (david987) Date: 2018-08-20 03:25
Sometimes, rarely, API calls will get stuck indefinitely on ssl.py. Stack trace:

  response = json.loads(urllib.request.urlopen(req).read())
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/lib/python3.6/http/client.py", line 1400, in connect
    server_hostname=server_hostname)
  File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib/python3.6/ssl.py", line 814, in __init__
    self.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()


Almost identical issue as https://stackoverflow.com/questions/19938593/web-app-hangs-for-several-hours-in-ssl-py-at-self-sslobj-do-handshake
But using python 3.6
msg323787 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-08-20 12:10
It's hard to say what the culprit is. A blocked handshake often indicates a network or a server problem. Either something went wrong between the client and the server or the server refuses to finalize the handshake.

I suggest that you add a timeout and handle the timeout from our application. There is nothing I can do from Python's ssl module.
History
Date User Action Args
2022-04-11 14:59:04adminsetgithub: 78619
2018-08-20 12:10:54christian.heimessetstatus: open -> closed
type: behavior
messages: + msg323787

resolution: not a bug
stage: resolved
2018-08-20 03:25:35david987create