Error: Tried to send "500 Server Error" to client but received socket error (When user closes browser during load, or when using the requests library.)

22 views
Skip to first unread message

hiro

unread,
Oct 14, 2019, 3:21:44 AM10/14/19
to web2py-users
Hi, I am building a dashboard/API and am seeing this error a lot in my logs:

ERROR:Rocket.Errors.Thread-3:Tried to send "500 Server Error" to client but received socket errorERROR:Rocket.Errors.Thread-6:Traceback (most recent call last):

 
File "/opt/app-root/src/gluon/rocket.py", line 1288, in run
   
self.run_app(conn)

 
File "/opt/app-root/src/gluon/rocket.py", line 1781, in run_app
   
self.environ = environ = self.build_environ(sock_file, conn)

 
File "/opt/app-root/src/gluon/rocket.py", line 1601, in build_environ
    request
= self.read_request_line(sock_file)

 
File "/opt/app-root/src/gluon/rocket.py", line 1339, in read_request_line
    d
= sock_file.readline()

 
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/socket.py", line 586, in readinto
   
return self._sock.recv_into(b)

ConnectionResetError: [Errno 104] Connection reset by peer



I notice it happens in two situations:

1. If a client connects with a browser and then closes the browser before the page loaded succesfully.
2. If the client usus an API, and sent the request using the requests library or the curl application.

Notice that this does not cause a real error for the API call, just an entry in the error log. But it is quite annoying have the logs filled up with this, as we are planning to use curl and requests a lot.

I have tried running rquests with sessions, setting headers, using http/https, ignoring ssl verification; but I am always getting this error when using curl or requests (Not that powershells Invoke-WebRequest does not trigger this error.)

2.18.5-stable+timestamp.2019.04.08.04.22.03
(Running on Rocket 1.2.6, Python 3.6.3)


NAME
="Red Hat Enterprise Linux Server"
VERSION
="7.6 (Maipo)"
ID
="rhel"
ID_LIKE
="fedora"
VARIANT
="Server"
VARIANT_ID
="server"
VERSION_ID
="7.6"
PRETTY_NAME
="Red Hat Enterprise Linux Server 7.6 (Maipo)"
ANSI_COLOR
="0;31"
CPE_NAME
="cpe:/o:redhat:enterprise_linux:7.6:GA:server"
HOME_URL
="https://www.redhat.com/"
BUG_REPORT_URL
="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT
="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION
=7.6
REDHAT_SUPPORT_PRODUCT
="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION
="7.6"

Trying to figure out why so I can stop this error. I guess I could try a different webserver, but would be glad if I could keep config to a minimum.
Reply all
Reply to author
Forward
0 new messages