How to debug: ConnectionResetError: [Errno 54] Connection reset by peer - django

I am now trying to debug this error in django for ages. Is someone able to help me? The reason for this error is that I am doing a successful ajax call, however, then at the end the error is thrown. Please see:
Exception happened during processing of request from ('127.0.0.1', 59734)
Traceback (most recent call last):
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "4_Code/Floq_Django/venv/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "Floq_Django/venv/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
Thank you so much.

Related

Django [WinError 10053] when loading up server

Whenever I start up my Django server i get the errors shown below. The weird thing is that sometimes the [WinError 10053] doesn't show up and I can develop normally but when it does show up the project seems to malfunction and .css and .js files also don't get loaded.
I have already looked into other stackoverflow questions that seemed related such as setting the correct code page to use with postgres or the python bug mentioned here https://bugs.python.org/issue27682. But I'm using python 3.9 so that bug should be fixed.
Does anyone know how to fix this? The project works just fine on the computers of some other people and everything that we compared seemed the same (settings, pycharm configuration,...).
Exception occurred during processing of request from ('127.0.0.1', 59986)
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 55047)
Traceback (most recent call last):
File "D:\DataDownloads\lib\socketserver.py", line 683, in process_request_thread
self.finish_request(request, client_address)
Traceback (most recent call last):
File "D:\DataDownloads\lib\socketserver.py", line 683, in process_request_thread
self.finish_request(request, client_address)
File "D:\DataDownloads\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "D:\DataDownloads\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "D:\DataDownloads\lib\socketserver.py", line 747, in __init__
self.handle()
File "D:\Documents - data drive\StepDB\gitlab\site\Site\venv\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "D:\Documents - data drive\StepDB\gitlab\site\Site\venv\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "D:\DataDownloads\lib\socket.py", line 704, in readinto
return self._sock.recv_into(b)
ConnectionAbortedError: [WinError 10053] De software op uw hostcomputer heeft een verbinding verbroken
File "D:\DataDownloads\lib\socketserver.py", line 747, in __init__
self.handle()
File "D:\Documents - data drive\StepDB\gitlab\site\Site\venv\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "D:\Documents - data drive\StepDB\gitlab\site\Site\venv\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
----------------------------------------
File "D:\DataDownloads\lib\socket.py", line 704, in readinto
return self._sock.recv_into(b)
ConnectionAbortedError: [WinError 10053] De software op uw hostcomputer heeft een verbinding verbroken
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 64741)
Traceback (most recent call last):
File "D:\DataDownloads\lib\socketserver.py", line 683, in process_request_thread
self.finish_request(request, client_address)
File "D:\DataDownloads\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "D:\DataDownloads\lib\socketserver.py", line 747, in __init__
self.handle()
File "D:\Documents - data drive\StepDB\gitlab\site\Site\venv\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "D:\Documents - data drive\StepDB\gitlab\site\Site\venv\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "D:\DataDownloads\lib\socket.py", line 704, in readinto
return self._sock.recv_into(b)
ConnectionAbortedError: [WinError 10053] De software op uw hostcomputer heeft een verbinding verbroken
----------------------------------------
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 59454)
Traceback (most recent call last):
File "D:\DataDownloads\lib\socketserver.py", line 683, in process_request_thread
self.finish_request(request, client_address)
File "D:\DataDownloads\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "D:\DataDownloads\lib\socketserver.py", line 747, in __init__
self.handle()
File "D:\Documents - data drive\StepDB\gitlab\site\Site\venv\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "D:\Documents - data drive\StepDB\gitlab\site\Site\venv\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "D:\DataDownloads\lib\socket.py", line 704, in readinto
return self._sock.recv_into(b)
ConnectionAbortedError: [WinError 10053] De software op uw hostcomputer heeft een verbinding verbroken
--------------------------------------

Every request being sent by Firefox triggers ConnectionResetError

For some reason Firefox, and only Firefox is causing this problem. Django server is still functional and I'm able to navigate, but stack trace keeps appearing on terminal.
Steps to reproduce problem:
Start django app (python3 manage.py runserver),
Open client/browser(firefox) and go to localhost:8000,
Start making requests / clicking URLs / anything that sends a request to Django
Terminal stack trace:
Exception happened during processing of request from ('127.0.0.1', 55364)
Exception happened during processing of request from ('127.0.0.1', 55366)
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/orion/Desktop/Claymore/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 171, in handle
self.handle_one_request()
File "/Users/orion/Desktop/Claymore/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
----------------------------------------
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/orion/Desktop/Claymore/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 171, in handle
self.handle_one_request()
File "/Users/orion/Desktop/Claymore/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
----------------------------------------
For some reason Chrome and Safari do not trigger the socket / connection reset. Not sure what is happening here.

Django Errors in terminal

I'm running Django 2.17 and I get many many errors from the dev server, the terminal prints this error 5 or six times on every requestx to the dev server.
Trying to add --verbosity 0 to the runserver command does not supress them.
I want to print from functions in views, but I don't need the errors from django.
Someone on the django IRC channel told me that they were normal... but it looks as if something is not configured correctly to me.
EDITED IN:
Traceback (most recent call last):
File "c:\python\Lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "c:\python\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "c:\python\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "c:\python\Lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "c:\python\Lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "c:\python\Lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "c:\python\Lib\socketserver.py", line 796, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
Traceback (most recent call last):
File "c:\python\Lib\socketserver.py", line 647, in process_request_thread
self.finish_request(request, client_address)
File "c:\python\Lib\socketserver.py", line 647, in process_request_thread
self.finish_request(request, client_address)
File "c:\python\Lib\socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "c:\python\Lib\socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "c:\python\Lib\socketserver.py", line 717, in __init__
self.handle()
File "c:\python\Lib\socketserver.py", line 717, in __init__
self.handle()
File "C:\Python\virtualenvs\tools\lib\site-packages\django\core\servers\basehttp.py", line 151, in handle
self.handle_one_request()
File "C:\Python\virtualenvs\tools\lib\site-packages\django\core\servers\basehttp.py", line 153, in handle
self.handle_one_request()
File "C:\Python\virtualenvs\tools\lib\site-packages\django\core\servers\basehttp.py", line 176, in handle_one_request
handler.run(self.server.get_app())
File "C:\Python\virtualenvs\tools\lib\site-packages\django\core\servers\basehttp.py", line 176, in handle_one_request
handler.run(self.server.get_app())
File "c:\python\Lib\wsgiref\handlers.py", line 144, in run
self.close()
File "c:\python\Lib\wsgiref\handlers.py", line 144, in run
self.close()
File "c:\python\Lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
File "c:\python\Lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
AttributeError: 'NoneType' object has no attribute 'split'
--------------------------------------------------------------------------------
Looks like you are trying to split a variable that you expect to be str but which is somehow NoneType (None) instead.

Django API Rest Framework and Angular 7 Authentication with jwt token

I am using Django Rest Framework for the back-end and Angular 7 for the user interface. I'm trying to create a login page to my single page application and authenticate with a jwt token. I've already managed the back-end and it works. Whenever i go to /api-token-auth/ and type the credentials i get a token in the rest framework interface.
The front-end part though troubles me. I have created the login component, the authorization service and a token interceptor. I believe i did the right adjustments but whenever i try to login from angular this error appears in the django command promt.
"Bad Request: /api-token-auth/ [19/Nov/2018 20:16:16] "POST
/api-token-auth/ HTTP/1.1" 400 68 Traceback (most recent call last):
File "C:\Python36\lib\wsgiref\handlers.py", line 138, in run
self.finish_response() File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data) File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers() File "C:\Python36\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble() File "C:\Python36\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1') File
"C:\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data) File "C:\Python36\lib\socketserver.py", line 775, in write
self._sock.sendall(b) ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host
machine [19/Nov/2018 20:16:16] "POST /api-token-auth/ HTTP/1.1" 500 59
---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 51566) Traceback (most recent
call last): File "C:\Python36\lib\wsgiref\handlers.py", line 138, in
run
self.finish_response() File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data) File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers() File "C:\Python36\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble() File "C:\Python36\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1') File
"C:\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data) File "C:\Python36\lib\socketserver.py", line 775, in write
self._sock.sendall(b) ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host
machine
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Python36\lib\wsgiref\handlers.py", line 141, in run
self.handle_error() File "C:\Python36\lib\site-packages\django\core\servers\basehttp.py", line
86, in handle_error
super().handle_error() File "C:\Python36\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response() File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data) File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers() File "C:\Python36\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern(): File "C:\Python36\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9' TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Python36\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address) File "C:\Python36\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self) File "C:\Python36\lib\socketserver.py", line 696, in init
self.handle() File "C:\Python36\lib\site-packages\django\core\servers\basehttp.py", line
154, in handle
handler.run(self.server.get_app()) File "C:\Python36\lib\wsgiref\handlers.py", line 144, in run
self.close() File "C:\Python36\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent AttributeError: 'NoneType' object has no attribute 'split'"
I'm really trying to understand what is going on based in this error. Anybody has an idea? Thanks
UPDATE
I had never imported the FormsModuls and apparently that was causing the issue.
line 35, in close self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
Due to some reason, the attribute self.status is returning None which cannot be split, thus, causing errors.

Django larger videos are not rendering

I have a django app that is serving video files that were uploaded by a user and saved. The videos that are 1 second and 2 seconds work and embed just fine, but the videos that are 24-27 seconds don't render and produce the following errors:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 86, in run
self.finish_response()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 128, in finish_response
self.write(data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 217, in write
self._write(data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 324, in write
self.flush()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
[10/Aug/2014 09:17:41] "GET /media/mbaron/video3.MOV HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 49384)
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Python/2.7/site-packages/django/core/servers/basehttp.py", line 139, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 651, in __init__
self.finish()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 710, in finish
self.wfile.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 279, in close
self.flush()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
I'm rendering a video with the following code in my template:
<video controls="controls" width="800" height="600" name="Video Name" src="/media/{{ profile.video2 }}"></video>
Thanks for your help!