#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.e1038717eb317ced6b3e39eda537d0cd%40djangoproject.com.

Reply via email to