non existant https site hangs

The following hangs: 

requests.get("https://nonexistant-1111111111.blib.us") 

When one uses this url on chrome/firefox, they right away say its non existant or connection was reset.  This is a https sni server. 

Does this belong to a unit test?  

Another related problem:

requests.get("https://register.blib.us", verify=False, timeout=3.0) -> SSLError

but both the following commands work fine (and get done within 5 seconds):

requests.get("https://register.blib.us", verify=False)
requests.get("https://register.blib.us")

Any ideas if we are doing something wrong here? 


Hi there, thanks for raising this issue!

Firstly, I can't reproduce any of these problems. Can I quickly check what version of Requests you're running?

``` python
import requests
print requests.__version__
```


I can reproduce the timeout error. But only when using python2 and the pyopenssl codepath (requiring ndg-httpsclient and pyasn1)


I just tried to reproduce the problem. Here is what I got:

C:\Python27>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

> > > import requests
> > > requests.**version**
> > > '1.2.3'
> > > requests.get("https://nonexistant-1111111111.blib.us")

... hangs ... Ctrl+C is disabled.

The other calls behave differently on my machine:

c:\Python27>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

> > > import requests
> > > requests.get("https://register.blib.us", verify=False, timeout=3.0)
> > > <Response [200]>
> > > requests.get("https://register.blib.us", verify=False)
> > > <Response [200]>
> > > requests.get("https://register.blib.us")
> > > <Response [200]>

The above calls all returned status 200. 


@pikumar can you reproduce the issue with the hanging request?
I tried to reproduce this but I can't.

Maybe some sort of personal firewall on your workstation interferes?
I have seen a firewall that ninja-encrypted all outgoing traffic to port 993...


@t-8ch Here are three machines I tried it on: (2 Windows7 boxes and 1 Ubuntu)

# 

c:\Python27\Scripts>..\python.exe
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

> > > import requests
> > > requests.get("https://nonexistant-1111111111.blib.us")
> > > <Hangs>

Ctrl+C does not work anymore.

# 

Machine 2 (Windows 7 again):

c:\Python27>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

> > > import requests
> > > requests.get("https://nonexistant-1111111111.blib.us")
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in <module>
> > >   File "c:\Python27\lib\site-packages\requests\api.py", line 55, in get
> > >     return request('get', url, *_kwargs)
> > >   File "c:\Python27\lib\site-packages\requests\api.py", line 44, in request
> > >     return session.request(method=method, url=url, *_kwargs)
> > >   File "c:\Python27\lib\site-packages\requests\sessions.py", line 354, in request
> > >     resp = self.send(prep, *_send_kwargs)
> > >   File "c:\Python27\lib\site-packages\requests\sessions.py", line 460, in send
> > >     r = adapter.send(request, *_kwargs)
> > >   File "c:\Python27\lib\site-packages\requests\adapters.py", line 246, in send
> > >     raise ConnectionError(e)
> > > requests.exceptions.ConnectionError: HTTPSConnectionPool(host='nonexistant-1111111111.blib.us', port=443): Max retries exceeded with url: / (Caused by <class 'socket.error'>: [Errno 10054] An existing connection was forcibly closed by the remote host)

# 

Machine 3 (ubuntu box):

> > > requests.get("https://nonexistant-1111111111.blib.us")
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in <module>
> > >   File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 55, in get
> > >     return request('get', url, *_kwargs)
> > >   File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 44, in request
> > >     return session.request(method=method, url=url, *_kwargs)
> > >   File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 354, in request
> > >     resp = self.send(prep, *_send_kwargs)
> > >   File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 460, in send
> > >     r = adapter.send(request, *_kwargs)
> > >   File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 246, in send
> > >     raise ConnectionError(e)
> > > requests.exceptions.ConnectionError: HTTPSConnectionPool(host='nonexistant-1111111111.blib.us', port
> > > =443): Max retries exceeded with url: / (Caused by <class 'socket.error'>: [Errno 104] Connection re
> > > set by peer)

========================================== Back to Machine 1

On Machine 1 where things hang, if I change the timeout:

> > > requests.get("https://nonexistant-1111111111.blib.us", timeout=5.0)
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in <module>
> > >   File "c:\Python27\lib\site-packages\requests-1.2.3-py2.7.egg\requests\api.py",
> > >  line 55, in get
> > >     return request('get', url, *_kwargs)
> > >   File "c:\Python27\lib\site-packages\requests-1.2.3-py2.7.egg\requests\api.py",
> > >  line 44, in request
> > >     return session.request(method=method, url=url, *_kwargs)
> > >   File "c:\Python27\lib\site-packages\requests-1.2.3-py2.7.egg\requests\sessions
> > > .py", line 335, in request
> > >     resp = self.send(prep, *_send_kwargs)
> > >   File "c:\Python27\lib\site-packages\requests-1.2.3-py2.7.egg\requests\sessions
> > > .py", line 438, in send
> > >     r = adapter.send(request, *_kwargs)
> > >   File "c:\Python27\lib\site-packages\requests-1.2.3-py2.7.egg\requests\adapters
> > > .py", line 331, in send
> > >     raise SSLError(e)
> > > requests.exceptions.SSLError: _ssl.c:489: The handshake operation timed out

I am guessing that when one does not provide a timeout, this is the place where the code hangs? (And ctrl+c is disabled ? )


Machine 2 and 3 behave correctly. `blib.us` resets the connection instead of sending a default certificate if SNI requests a nonexistent subdomain.
The fact the machine doesn't react to abort signal indicates, that it is stuck in a system call.

Whats the difference between machines 1 and 2?
I suspect some sort of firewall dropping TCP RST packets.


Machine 1 is a virtual machine installed inside Machine 2. (Win 7 guest/host). Vbox guest is a usual NAT configuration. I just checked on Machine 1. Firefox and IE hang as well! So I guess it is not requests that has the problem. I guess time to close the issue? 


Mm, this looks like it isn't a Requests issue. I do hope you work out what's going on, though, @pikumar!

Thanks again @t-8ch!