﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29849	"runserver crashes with ""Remote end closed connection without response"""	rvernica	nobody	"I created an app like in the tutorial and started Django. When I issue successive requests, the session gets disconnected. Here is an example:
{{{
>>> s = requests.Session()
>>> s.get('http://localhost:8000/'); s.get('http://localhost:8000')
<Response [404]>
Traceback (most recent call last):
  File ""...local/lib/python3.6/site-packages/urllib3/connectionpool.py"", line 600, in urlopen
    chunked=chunked)
  File ""...local/lib/python3.6/site-packages/urllib3/connectionpool.py"", line 384, in _make_request
    six.raise_from(e, None)
  File ""<string>"", line 2, in raise_from
  File ""...local/lib/python3.6/site-packages/urllib3/connectionpool.py"", line 380, in _make_request
    httplib_response = conn.getresponse()
  File ""/usr/lib64/python3.6/http/client.py"", line 1331, in getresponse
    response.begin()
  File ""/usr/lib64/python3.6/http/client.py"", line 297, in begin
    version, status, reason = self._read_status()
  File ""/usr/lib64/python3.6/http/client.py"", line 266, in _read_status
    raise RemoteDisconnected(""Remote end closed connection without""
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ""...local/lib/python3.6/site-packages/requests/adapters.py"", line 445, in send
    timeout=timeout
  File ""...local/lib/python3.6/site-packages/urllib3/connectionpool.py"", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File ""...local/lib/python3.6/site-packages/urllib3/util/retry.py"", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File ""...local/lib/python3.6/site-packages/urllib3/packages/six.py"", line 685, in reraise
    raise value.with_traceback(tb)
  File ""...local/lib/python3.6/site-packages/urllib3/connectionpool.py"", line 600, in urlopen
    chunked=chunked)
  File ""...local/lib/python3.6/site-packages/urllib3/connectionpool.py"", line 384, in _make_request
    six.raise_from(e, None)
  File ""<string>"", line 2, in raise_from
  File ""...local/lib/python3.6/site-packages/urllib3/connectionpool.py"", line 380, in _make_request
    httplib_response = conn.getresponse()
  File ""/usr/lib64/python3.6/http/client.py"", line 1331, in getresponse
    response.begin()
  File ""/usr/lib64/python3.6/http/client.py"", line 297, in begin
    version, status, reason = self._read_status()
  File ""/usr/lib64/python3.6/http/client.py"", line 266, in _read_status
    raise RemoteDisconnected(""Remote end closed connection without""
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ""<stdin>"", line 1, in <module>
  File ""...local/lib/python3.6/site-packages/requests/sessions.py"", line 525, in get
    return self.request('GET', url, **kwargs)
  File ""...local/lib/python3.6/site-packages/requests/sessions.py"", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File ""...local/lib/python3.6/site-packages/requests/sessions.py"", line 622, in send
    r = adapter.send(request, **kwargs)
  File ""...local/lib/python3.6/site-packages/requests/adapters.py"", line 495, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
}}}

It I have a small timeout between the requests it works fine:
{{{
>>> s = requests.Session()
>>> s.get('http://localhost:8000/'); time.sleep(1); s.get('http://localhost:8000')
<Response [404]>
<Response [404]>
}}}

It also works fine if I don't use sessions:
{{{
>>> requests.get('http://localhost:8000/'); requests.get('http://localhost:8000')
<Response [404]>
<Response [404]>
}}}

I initially reported this as a bug in the `requests` library but it does not appear to be the case. See discussion here https://github.com/requests/requests/issues/4784"	Bug	closed	HTTP handling	2.1	Normal	fixed		Jaap Roes	Ready for checkin	1	0	0	0	0	0
