[New-bugs-announce] [issue5103] ssl.SSLSocket timeout not working correctly when remote end is hanging

Jacques Grove report at bugs.python.org
Thu Jan 29 23:44:27 CET 2009


New submission from Jacques Grove <jacques at tripitinc.com>:

In ssl.py of Python 2.6.1 we have this code in  SSLSocket.__init__():

            if do_handshake_on_connect:
                timeout = self.gettimeout()
                try:
                    self.settimeout(None)
                    self.do_handshake()
                finally:
                    self.settimeout(timeout)

The problem is, what happens if the remote end (server) is hanging when
do_handshake() is called?  The result is that the user-requested timeout
will be ignored, and the connection will hang until the TCP socket
timeout expires.

This is easily reproducable with this test code:


import urllib2
urllib2.urlopen("https://localhost:9000/", timeout=2.0)


and running netcat on port 9000, i.e.:

nc -l -p 9000 localhost

If you use "http" instead of "https", the timeout works as expected
(after 2 seconds in this case).

----------
components: Library (Lib)
messages: 80790
nosy: jacques
severity: normal
status: open
title: ssl.SSLSocket timeout not working correctly when remote end is hanging
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5103>
_______________________________________


More information about the New-bugs-announce mailing list