pythondjangodjango-socialauthgraphene-python

Django How can I trace back where this call is done


Since I created a new project (Django 2.2 and Python 3.7) I am having this error been printed periodically each 60s.

Not Found: /graphql
[24/Sep/2019 13:23:50] "GET /graphql HTTP/1.1" 404 4216
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 53701)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/Users/robertofernandez/KMH/flowlemon_backen/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 171, in handle
    self.handle_one_request()
  File "/Users/robertofernandez/KMH/flowlemon_backen/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 179, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer

I think this error is caused by some dependency that I have installed (I don't have any view or URL call graphql and I am not using graphql at all in my project), but I am unable to detect which package is the one causing the problems.

requirements.txt

attrs==19.1.0
certifi==2019.6.16
chardet==3.0.4
coreapi==2.3.3
coreschema==0.0.4
defusedxml==0.6.0
Django==2.2.4
django-braces==1.13.0
django-cors-headers==3.1.0
django-extensions==2.2.1
django-filter==2.2.0
django-oauth-toolkit==1.2.0
django-rest-framework-social-oauth2==1.1.0
djangorestframework==3.10.2
drf-yasg==1.16.1
idna==2.8
inflection==0.3.1
itypes==1.1.0
Jinja2==2.10.1
loguru==0.3.2
MarkupSafe==1.1.1
oauthlib==3.1.0
packaging==19.1
PyJWT==1.7.1
pyparsing==2.4.2
python-decouple==3.1
python3-openid==3.1.0
pytz==2019.2
requests==2.22.0
requests-oauthlib==1.2.0
ruamel.yaml==0.16.5
ruamel.yaml.clib==0.1.2
six==1.12.0
social-auth-app-django==3.1.0
social-auth-core==3.2.0
sqlparse==0.3.0
uritemplate==3.0.0
urllib3==1.25.3

Any idea of how I could trace this?


Solution

  • My hunch is that it's a frontend package that's causing this error, since Django packages typically don't need to make HTTP requests to the Django server. Also, the fact that it's happening periodically is an indication of client pollling. For example, perhaps you have the Apollo client?

    To answer your question specifically, you could add a route at /graphql and then inspect the request's client and referrer.

    1) Update urls.py with a temporary route to a debug view

    urlpatterns = [
        ...
        path('graphql', my_debug_view),
        ]
    

    2) Add a debug view to show request information on the runserver console using print

    from django.http import HttpResponse
    
    def my_debug_review(request):
        print(request.META)
        return HttpResponse("")
    

    Now, instead of a 404 error every 60 seconds you'd see information about the request.

    When you're done, don't forget to remove these changes.