[Django] #33115: Connection issue after a HEAD is used

14 views
Skip to first unread message

Django

unread,
Sep 16, 2021, 7:57:11 PM9/16/21
to django-...@googlegroups.com
#33115: Connection issue after a HEAD is used
----------------------------------------+---------------------------
Reporter: daveisfera | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 2.2
Severity: Normal | Keywords: keepalive
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+---------------------------
We noticed that monitoring checks using HEAD were causing
`ConnectionResetError` issues in our logs. We believe that this may be
causing issues with some other requests, but haven't been able to verify
that yet. However, there's a simple way to reproduce this issue. Simply
[[https://docs.djangoproject.com/en/3.2/intro/tutorial01/|create a new
project and run it using the instructions from the tutorial]] and then run
a command like this `curl -I http://localhost:8000/
http://localhost:8000/` or run a Python script like this:
{{{
import logging

import requests

logging.basicConfig(level=logging.DEBUG)
s = requests.Session()

r = s.head('http://localhost:8000/')
print(r.status_code, r.text)
r = s.head('http://localhost:8000/')
print(r.status_code, r.text)
}}}

And you'll notice an output like this:
{{{
16/Sep/2021 16:02:17] "HEAD / HTTP/1.1" 200 16348
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 44808)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/socketserver.py", line 650, in
process_request_thread
self.finish_request(request, client_address)
File "/usr/local/lib/python3.7/socketserver.py", line 360, in
finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python3.7/socketserver.py", line 720, in __init__
self.handle()
File "/usr/local/lib/python3.7/site-
packages/django/core/servers/basehttp.py", line 171, in handle
self.handle_one_request()
File "/usr/local/lib/python3.7/site-
packages/django/core/servers/basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
----------------------------------------
[16/Sep/2021 16:02:18] "HEAD / HTTP/1.1" 200 16348
}}}

Or with 3.2, an output like this:
{{{
[16/Sep/2021 23:31:37] "HEAD / HTTP/1.1" 200 10697
[16/Sep/2021 23:31:37,819] - Broken pipe from ('127.0.0.1', 46600)

[16/Sep/2021 23:31:45] "HEAD / HTTP/1.1" 200 10697
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33115>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 17, 2021, 12:40:28 AM9/17/21
to django-...@googlegroups.com
#33115: Connection issue after a HEAD is used
-------------------------------+--------------------------------------
Reporter: Dave Johansen | Owner: nobody
Type: Bug | Status: closed
Component: HTTP handling | Version: 2.2
Severity: Normal | Resolution: duplicate

Keywords: keepalive | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate
* component: Core (Other) => HTTP handling


Comment:

It's a duplicate of #28054 and #29343, the proposed
[https://github.com/django/django/pull/10676 PR] fixes this issue for me.

--
Ticket URL: <https://code.djangoproject.com/ticket/33115#comment:1>

Reply all
Reply to author
Forward
0 new messages