Opened 12 years ago

Closed 12 years ago

#10117 closed (duplicate)

Test server sometimes causes 'Connection reset by peer' when retrieving POST data

Reported by: Almad Owned by: nobody
Component: HTTP handling Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When I create a view that returns 401 Unauthorized:

from django.http import HttpResponse
class HttpResponseNotAuthorized(HttpResponse):
    status_code = 401

def return_not_authorized(request):
    return HttpResponseNotAuthorized("401 Not Authorized")

and I wan't to POST some data using urllib2:

        for i in xrange(1, 10):
            response = urllib2.urlopen(url='http://%(host)s:%(port)s/return_not_authorized/' % {
                'host' : 'localhost',
                'port' : 8000

I non-deterministically (thus the xrange cycle) get 'Connection reset by peer':

  File "//usr/lib/python2.5/", line 124, in urlopen
    return, data)
  File "//usr/lib/python2.5/", line 381, in open
    response = self._open(req, data)
  File "//usr/lib/python2.5/", line 399, in _open
    '_open', req)
  File "//usr/lib/python2.5/", line 360, in _call_chain
    result = func(*args)
  File "//usr/lib/python2.5/", line 1107, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "//usr/lib/python2.5/", line 1082, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error (104, 'Connection reset by peer')>

Tested on both 1.0 and SVN HEAD. Send agains server run by ./ runserver.

Change History (6)

comment:1 Changed 12 years ago by Ramiro Morales

What happens if you insert a delay in the loop between requests?, remember the Django development server is single-threaded.

comment:2 Changed 12 years ago by Almad

ramiro: Problem is that mostly You get error on first request (i.e. no loop needed)...

comment:3 Changed 12 years ago by Almad

Resolution: duplicate
Status: newclosed

After some investigation, it probably is a duplicate to #3357. Damn.

comment:4 Changed 12 years ago by mawe

Looks like your problem isn't that the dev server is single threaded, but it could be a bug in wsgiref:

comment:5 Changed 12 years ago by Almad

Resolution: duplicate
Status: closedreopened

OK, I'll reopen it for reference.

comment:6 Changed 12 years ago by Jacob

Resolution: duplicate
Status: reopenedclosed

No, this is indeed a duplicate of #3357.

Note: See TracTickets for help on using tickets.
Back to Top