I'm sending a file with the following route
#app.route('/file/')
#db_session
def file():
filename = request.args.get('filename')
response = make_response(filename)
response.headers['Content-Type'] = 'video/mp3'
response.headers["Content-Disposition"] = 'attachment; filename=%s' % filename
response.headers['Content-Length'] = os.path.getsize(filename)
response.headers["X-Accel-Redirect"] = '%s' % filename
return send_file(
filename,
mimetype="audio/mp3",
as_attachment=True,
attachment_filename="%s" % filename)
It works fine in most desktop browsers and some mobile browsers. But on others it does not, and I get this error
68.9.161.152 - - [13/Dec/2015 05:27:24] "GET /mp4/?filename=video/How_To_Shave_Your_Beard_Like_A_Man.mp4 HTTP/1.1" 200 -
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 653, in inner
fd=fd).serve_forever()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 505, in serve_forever
HTTPServer.serve_forever(self)
File "/usr/lib/python2.7/SocketServer.py", line 238, in serve_forever
self._handle_request_noblock()
File "/usr/lib/python2.7/SocketServer.py", line 297, in _handle_request_noblock
self.handle_error(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 217, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 252, in handle_one_request
return self.run_wsgi()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 194, in run_wsgi
execute(self.server.app)
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 185, in execute
write(data)
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 166, in write
self.wfile.write(data)
I've tried putting time.sleep(1) randomly in order to try and help.
Related
When running Flask scripts in localhost, I tried to access the webpages from another device in the same local network.
Although I'm able to view the webpages, I frequently noticed this error popping all of a sudden with random numbers near my IP in my console causing OSError and denying access for my later requests to the Flask server.
Exception happened during processing of request from ('192.168.0.4', 41252)
Exception happened during processing of request from ('192.168.0.4', 41250)
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python38\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python38\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python38\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Program Files\Python38\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 329, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "C:\Program Files\Python38\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Program Files\Python38\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 329, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "C:\Program Files\Python38\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 360, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "C:\Program Files\Python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 360, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "C:\Program Files\Python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
OSError: [WinError 10022] An invalid argument was supplied
OSError: [WinError 10022] An invalid argument was supplied
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('192.168.0.4', 41378)
Exception happened during processing of request from ('192.168.0.4', 41380)
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python38\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python38\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python38\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python38\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Program Files\Python38\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 329, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 329, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "C:\Program Files\Python38\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 360, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "C:\Program Files\Python38\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 360, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "C:\Program Files\Python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "C:\Program Files\Python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
OSError: [WinError 10022] An invalid argument was supplied
OSError: [WinError 10022] An invalid argument was supplied
----------------------------------------
----------------------------------------
For all I know, I know nothing about sockets or other things thats in my error.
How do i stop such errors from happenning after all I'm just rendering a HTML template as a response?
Edit :
I'm adding a part of my Flask script here from which I still get the error. And again the error is something that occurs when I try to access my webpages from other devices connected in the network
from flask import *
app = Flask(__name__)
#app.route('/')
def index():
return render_template("home.html")
#app.route('/download')
def downloads():
return render_template("downloads.html")
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000 , debug = True)
This time also I got similar error as follows
----------------------------------------
Exception happened during processing of request from ('192.168.0.5', 42834)
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python38\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python38\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 329, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "C:\Program Files\Python38\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 360, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "C:\Program Files\Python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
OSError: [WinError 10022] An invalid argument was supplied
----------------------------------------
Does anyone know what I should do? I receive this error everytime I interact with my localhost.
It does not crash, my terminal just blows up with these exceptions. Does anyone know how I should proceed with this issue?
I know this is alot of errors but I am starting to learn more about Django so your help would be greatly appreciated. Thank you!
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50979)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50974)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50978)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50980)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50981)
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/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/Frameworks/Python.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
----------------------------------------
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/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/Frameworks/Python.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
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/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/Frameworks/Python.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
----------------------------------------
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/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/Frameworks/Python.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
----------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/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/Frameworks/Python.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
----------------------------------------
----------------------------------------
Not Found: /favicon.ico
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50982)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/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/Frameworks/Python.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
'''
The issue is raised by the fav.ico because django server is always resetting after not finding a favicon so If you add one. Even though If you never explicitly load one, django try and load a default one from the root of the project. you can use favicon io to make a simple fav icon. you put it inside your static folder and load it like that :
{% load static %}
<head>
<link rel="shortcut icon" href="{% static 'images/favicon.ico' %}" />
I am googling a lot to find the solution. Maybe this is windows or python bug. I am here for getting help. It is creating problem while debuging.
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 258, in send_preamble
self._write(('Server: %s\r\n' % self.server_software).encode('iso-8859-1'))
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 803, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
[19/Apr/2019 14:31:19] ERROR [django.server:154] "GET /static/node_modules/metronic-theme-classic/assets/media/logos/favicon.ico HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52183)
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 258, in send_preamble
self._write(('Server: %s\r\n' % self.server_software).encode('iso-8859-1'))
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 803, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
super().handle_error()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\azad\AppData\Local\Programs\Python\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:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 654, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 364, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 724, in __init__
self.handle()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
super().close()
File "C:\Users\azad\AppData\Local\Programs\Python\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'
----------------------------------------
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 333, in send_headers
self._write(bytes(self.headers))
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 803, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
[19/Apr/2019 14:31:21] ERROR [django.server:154] "GET /static/node_modules/metronic-theme-classic/assets/media/logos/favicon.ico HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52185)
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 333, in send_headers
self._write(bytes(self.headers))
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 803, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
super().handle_error()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\azad\AppData\Local\Programs\Python\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:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 654, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 364, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 724, in __init__
self.handle()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
super().close()
File "C:\Users\azad\AppData\Local\Programs\Python\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've got an NGINX/flask/Docker server using:
https://github.com/tiangolo/uwsgi-nginx-flask-docker
and it works for running small and infrequent requests. But if I try a number of large requests that involve downloading ~5mb worth of data from amazon s3 for each (lets say, 10 at once). I get this error:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/local/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 659, in inner
srv.serve_forever()
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 499, in serve_forever
HTTPServer.serve_forever(self)
File "/usr/local/lib/python2.7/SocketServer.py", line 233, in serve_forever
self._handle_request_noblock()
File "/usr/local/lib/python2.7/SocketServer.py", line 292, in _handle_request_noblock
self.handle_error(request, client_address)
File "/usr/local/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/local/lib/python2.7/SocketServer.py", line 318, in process_request
self.finish_request(request, client_address)
File "/usr/local/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 216, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "/usr/local/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 251, in handle_one_request
return self.run_wsgi()
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 193, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 184, in execute
write(data)
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in write
self.wfile.write(data)
IOError: [Errno 32] Broken pipe
I've tried adding more processes and threads to nginx/wsgi. My uwsgi.ini looks like so:
[uwsgi]
module = main
callable = application
processes = 8
threads = 2
and my nginx.conf looks like this:
server {
location / {
try_files $uri #app;
}
location #app {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi.sock;
}
location /static {
alias /app/static;
}
}
Does anyone know what might be causing this?
when i run my code the printer.py returns the below error
Error: printer.py
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 596, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "server.py", line 67, in do_GET
print_dev = Usb(connected[0]['vendor'], connected[0]['product'])
File "/home/acespritech/projects/Printing Code/escpos/printer.py", line 32, in __init__
self.open()
File "/home/acespritech/projects/Printing Code/escpos/printer.py", line 60, in open
self.out_ep = endpoint_out.bEndpointAddress
AttributeError: 'NoneType' object has no attribute 'bEndpointAddress'