I am using Python 2.7.5. I have a web app which queries an API every few minutes and has been working successfully for the last day or so. However, after leaving it sitting for a few hours, I came back to find my program stalled with no activity for several hours. I quit the program and found that it has been stalled in the ssl handshake method for most of the day, during one of the API calls.
Here is the traceback:
...
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 143, in __init__
self.do_handshake()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 305, in do_handshake
self._sslobj.do_handshake()
I did a little research, and it seems that this was a problem with the SSL libraries in Python 2.6, but it has since been fixed. I'm wondering why my program got stuck here without throwing an exception or anything.
If there is a way to set a timeout for the SSL handshake method, I would gladly do that, as I would like to avoid my program being stopped indefinitely from something like this again. I am using the Requests HTTP library and this is running on Mac OSX 10.9, if that matters. Suggestions?
EDIT: I did some research, and it seems that others have had this specific problem with SSL, despite the "fix" implemented in 2.6. Not sure what the solution is yet, however. Any help is appreciated.
EDIT 3: Added my solution as an answer to this question.
openssl s_client -connect mysslservice.example.com:443
return ? It could be waiting for you to provide a client certificate or stuck in a certificate validation that never completes. – Ramonramona