I'm getting this error below after set SESSION_EXPIRE_AT_BROWSER_CLOSE = True on my settings.py. I can open and login and logout with no errors...but if I close before login I get this error. Is there a way to fix it?
Thanks in advance!
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 63792)
Traceback (most recent call last):
File "c:\Python27\lib\SocketServer.py", line 582, in process_request_thread
self.finish_request(request, client_address)
File "c:\Python27\lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "c:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 150
, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "c:\Python27\lib\SocketServer.py", line 638, in __init__
self.handle()
File "c:\Python27\lib\wsgiref\simple_server.py", line 116, in handle
self.raw_requestline = self.rfile.readline()
File "c:\Python27\lib\socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10054] An existing connection was cancelled by the remote host
----------------------------------------
Related
I am currently going through 'The Definitive Guide to Celery and Django' course by testdriven.io. I've managed to containerize the whole application. Everything was built correctly and seemed to work just fine, but when I tried to enter the Django shell and run a task, to ensure everything works correctly, the following error appeared.
>>> divide.delay(1, 2)
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 30, in __call__
return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 446, in _reraise_as_library_errors
yield
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 433, in _ensure_connection
return retry_over_time(
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 312, in retry_over_time
return fun(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 877, in _connection_factory
self._connection = self._establish_connection()
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 812, in _establish_connection
conn = self.transport.establish_connection()
File "/usr/local/lib/python3.10/site-packages/kombu/transport/pyamqp.py", line 201, in establish_connection
conn.connect()
File "/usr/local/lib/python3.10/site-packages/amqp/connection.py", line 323, in connect
self.transport.connect()
File "/usr/local/lib/python3.10/site-packages/amqp/transport.py", line 129, in connect
self._connect(self.host, self.port, self.connect_timeout)
File "/usr/local/lib/python3.10/site-packages/amqp/transport.py", line 184, in _connect
self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 425, in delay
return self.apply_async(args, kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 575, in apply_async
return app.send_task(
File "/usr/local/lib/python3.10/site-packages/celery/app/base.py", line 788, in send_task
amqp.send_task_message(P, name, message, **options)
File "/usr/local/lib/python3.10/site-packages/celery/app/amqp.py", line 510, in send_task_message
ret = producer.publish(
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 177, in publish
return _publish(
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 523, in _ensured
return fun(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 186, in _publish
channel = self.channel
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 209, in _get_channel
channel = self._channel = channel()
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 32, in __call__
value = self.__value__ = self.__contract__()
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 225, in <lambda>
channel = ChannelPromise(lambda: connection.default_channel)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 895, in default_channel
self._ensure_connection(**conn_opts)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 432, in _ensure_connection
with ctx():
File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 450, in _reraise_as_library_errors
raise ConnectionError(str(exc)) from exc
kombu.exceptions.OperationalError: [Errno 111] Connection refused
I've done a quick research and in most cases it seemed to be a lack of the following lines
from config.celery import app as celery_app
__all__ = ['celery_app']
in the config.__init__.py, but it's clearly not an issue here.
I also double checked whether redis container is up and listening on port 6379.
The only difference between my code and the course code is that I decided to use Poetry package manager instead of requirements.txt file and pip.
At this point I am a little bit confused I'll be thankful for any tip. You can find the whole code below:
https://github.com/Kibraks/django-celery-app
i'm using django as a backend server and flutter as a mobile app.
when i request a 3d model from my django app the message
Exception occurred during processing of request from ('127.0.0.1', 49163)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 683, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 747, in __init__
self.handle()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/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.9/lib/python3.9/socket.py", line 704, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
but when i open the same file from another online server it works! what should i do?
I am using https://github.com/teddziuba/django-sslserver as an https server for my django-rest app. it works fine if I test it on admin or in chrome's api client(when admin runs on chrome as well). But whenever I try to test it from firefox, I get the following exception:
Exception happened during processing of request from ('127.0.0.1', 51984)
Traceback (most recent call last):
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 "/home/diwakar/virtualenvs/everybillapienv/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 102, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/home/diwakar/virtualenvs/everybillapienv/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 167, in handle
self.raw_requestline = self.rfile.readline(65537)
File "/usr/lib/python2.7/socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
File "/usr/lib/python2.7/ssl.py", line 341, in recv
return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 260, in read
return self._sslobj.read(len)
SSLError: [Errno 1] _ssl.c:1429: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca
Should I use that csrf_exempt decorator to get rid of this exception ? my app only have a mobile client, it would never have an browser/javascript client for sure.
How strong is django-sslserver ? Can I use it on production ?
What should be the easiest way to redirect http traffic to https here, I've heard a combination of easy-userena and django-privatebeta does it. Any suggestions ?
I'm running some basic functional web test with the Selenium web driver and I'm noticing this error in two of my functional web test cases. The test cases all pass at the end but I get this in the console:
Exception happened during processing of request from ('127.0.0.1', 1169)
data = self._sock.recv(self._rbufsize)
error: [Errno 10054] An existing connection was forcibly closed by the remote host
Traceback (most recent call last):
File "C:\dev\django-projects\barbwire\venv\lib\site-packages\django\test\testcases.py", line 981, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Python27\Lib\SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "C:\Python27\Lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\dev\django-projects\barbwire\venv\lib\site-packages\django\core\servers\basehttp.py", line 139, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "C:\Python27\Lib\SocketServer.py", line 638, in __init__
self.handle()
File "C:\Python27\Lib\wsgiref\simple_server.py", line 116, in handle
self.raw_requestline = self.rfile.readline()
File "C:\Python27\Lib\socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10054] An existing connection was forcibly closed by the remote host
Traceback (most recent call last):
File "C:\dev\django-projects\barbwire\venv\lib\site-packages\django\test\testcases.py", line 981, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Python27\Lib\SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "C:\Python27\Lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\dev\django-projects\barbwire\venv\lib\site-packages\django\core\servers\basehttp.py", line 139, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "C:\Python27\Lib\SocketServer.py", line 638, in __init__
self.handle()
File "C:\Python27\Lib\wsgiref\simple_server.py", line 116, in handle
self.raw_requestline = self.rfile.readline()
File "C:\Python27\Lib\socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 1170)
----------------------------------------
Destroying test database for alias 'default'...
Here's an example of one of the test cases:
def test_can_join_main_site(self):
self.browser.get(self.live_server_url)
self.browser.find_element_by_link_text('Register').click()
time.sleep(5)
self.browser.find_element_by_name('submit').click()
time.sleep(5)
It runs to completion but dumps the above exception. The idea is to test a simple registration page. After clicking the submit button the page re-displays and prompts the user to fill out additional form fields. As expected and everything appears to work correctly but why the errors? Am I missing something?
Replacing localhost with 127.0.0.1 did not work for me, and adding sleep just slows the test down. I was able to get rid of the error by calling refresh before quitting the browser:
from selenium import webdriver
browser = webdriver.Firefox()
# do stuff with browser
browser.refresh()
browser.quit()
In my case it was the loading of static files in <link> and <script> tags that was causing the problem. But it went away when I added refresh before quitting.
Using FireFox, I was able to resolve this by sufficiently slowing the shutdown process:
#classmethod
def tearDownClass(cls):
time.sleep(3)
cls.selenium.quit()
time.sleep(3)
super(TestClass, cls).tearDownClass()
I fixed the problem by replacing localhost with 127.0.0.1 in the URL:
url = self.live_server_url
url = url.replace('localhost', '127.0.0.1')
self.driver.get('%s%s' % (url, reverse('whatever')))
I found the solution here: https://code.djangoproject.com/ticket/15178
Django Debug Toolbar generates tons of these errors. uninstall it and try again
I am making a simple ajax request but for some reason request.is_ajax return false. I am using jquery and Django development server.
$('#save').click(
function()
{
$.ajax({
type: "POST",
url: "/order/start",
});
});
And in views.py
if request.POST and 'save' in request.POST :
if request.is_ajax()== True:
But, it does not return true, and on runserver i see errors
Exception happened during processing of request from ('127.0.0.1', 1625)
Traceback (most recent call last):
File "c:\python27\lib\SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "c:\python27\lib\SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "c:\python27\lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "c:\python27\lib\site-packages\django\core\servers\basehttp.py", line 56
, in __init__
BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
File "c:\python27\lib\SocketServer.py", line 641, in __init__
self.finish()
File "c:\python27\lib\SocketServer.py", line 694, in finish
self.wfile.flush()
File "c:\python27\lib\socket.py", line 301, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] An established connection was aborted by the software in y
ur host machine
I guess that you have the standard middleware enabled and settings.APPEND_SLASH is True (the default), which means that POSTing to "/order/start" automatically redirects to "/order/start/" with a slash, losing the POST in the process.
Make sure the URL in your JS ends with a slash.