Question

requests.exceptions ConnectionError Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')

Recently we have been facing this connection reset issue in our droplets. Especially when the digitalocean server gives a lot of get/post request to other remote servers like firebase,telegram etc. We didn’t face this problem when we were in GCP. After coming to digitalocean, it ran fine for few days. But recently we are facing this issue? Can you please help? Note: We may give 4/5 requests per second to other remote servers.

[2022-07-05 17:15:34,842: WARNING/ForkPoolWorker-2] Traceback (most recent call last):

[2022-07-05 17:15:34,843: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen

[2022-07-05 17:15:34,845: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,846: WARNING/ForkPoolWorker-2] httplib_response = self._make_request(
[2022-07-05 17:15:34,846: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,847: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 386, in _make_request

[2022-07-05 17:15:34,848: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,849: WARNING/ForkPoolWorker-2] self._validate_conn(conn)
[2022-07-05 17:15:34,849: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,850: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn

[2022-07-05 17:15:34,851: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,852: WARNING/ForkPoolWorker-2] conn.connect()
[2022-07-05 17:15:34,852: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,853: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 414, in connect

[2022-07-05 17:15:34,854: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,855: WARNING/ForkPoolWorker-2] self.sock = ssl_wrap_socket(
[2022-07-05 17:15:34,855: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,856: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket

[2022-07-05 17:15:34,857: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,858: WARNING/ForkPoolWorker-2] ssl_sock = _ssl_wrap_socket_impl(
[2022-07-05 17:15:34,858: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,859: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl

[2022-07-05 17:15:34,860: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,861: WARNING/ForkPoolWorker-2] return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
[2022-07-05 17:15:34,861: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,862: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/ssl.py", line 500, in wrap_socket

[2022-07-05 17:15:34,863: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,864: WARNING/ForkPoolWorker-2] return self.sslsocket_class._create(
[2022-07-05 17:15:34,864: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,865: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/ssl.py", line 1040, in _create

[2022-07-05 17:15:34,866: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,867: WARNING/ForkPoolWorker-2] self.do_handshake()
[2022-07-05 17:15:34,867: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,868: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/ssl.py", line 1309, in do_handshake

[2022-07-05 17:15:34,869: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,870: WARNING/ForkPoolWorker-2] self._sslobj.do_handshake()
[2022-07-05 17:15:34,870: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,871: WARNING/ForkPoolWorker-2] ConnectionResetError
[2022-07-05 17:15:34,871: WARNING/ForkPoolWorker-2] : 
[2022-07-05 17:15:34,872: WARNING/ForkPoolWorker-2] [Errno 104] Connection reset by peer
[2022-07-05 17:15:34,872: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,872: WARNING/ForkPoolWorker-2] 
During handling of the above exception, another exception occurred:


[2022-07-05 17:15:34,873: WARNING/ForkPoolWorker-2] Traceback (most recent call last):

[2022-07-05 17:15:34,874: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send

[2022-07-05 17:15:34,875: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,875: WARNING/ForkPoolWorker-2] resp = conn.urlopen(
[2022-07-05 17:15:34,876: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,876: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 785, in urlopen

[2022-07-05 17:15:34,878: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,879: WARNING/ForkPoolWorker-2] retries = retries.increment(
[2022-07-05 17:15:34,879: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,880: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 550, in increment

[2022-07-05 17:15:34,881: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,882: WARNING/ForkPoolWorker-2] raise six.reraise(type(error), error, _stacktrace)
[2022-07-05 17:15:34,882: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,883: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py", line 769, in reraise

[2022-07-05 17:15:34,884: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,884: WARNING/ForkPoolWorker-2] raise value.with_traceback(tb)
[2022-07-05 17:15:34,884: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,885: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen

[2022-07-05 17:15:34,886: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,886: WARNING/ForkPoolWorker-2] httplib_response = self._make_request(
[2022-07-05 17:15:34,887: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,887: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 386, in _make_request

[2022-07-05 17:15:34,888: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,888: WARNING/ForkPoolWorker-2] self._validate_conn(conn)
[2022-07-05 17:15:34,889: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,889: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn

[2022-07-05 17:15:34,891: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,891: WARNING/ForkPoolWorker-2] conn.connect()
[2022-07-05 17:15:34,892: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,892: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 414, in connect

[2022-07-05 17:15:34,893: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,894: WARNING/ForkPoolWorker-2] self.sock = ssl_wrap_socket(
[2022-07-05 17:15:34,894: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,895: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket

[2022-07-05 17:15:34,896: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,897: WARNING/ForkPoolWorker-2] ssl_sock = _ssl_wrap_socket_impl(
[2022-07-05 17:15:34,897: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,898: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl

[2022-07-05 17:15:34,899: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,899: WARNING/ForkPoolWorker-2] return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
[2022-07-05 17:15:34,900: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,900: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/ssl.py", line 500, in wrap_socket

[2022-07-05 17:15:34,901: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,901: WARNING/ForkPoolWorker-2] return self.sslsocket_class._create(
[2022-07-05 17:15:34,902: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,902: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/ssl.py", line 1040, in _create

[2022-07-05 17:15:34,903: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,904: WARNING/ForkPoolWorker-2] self.do_handshake()
[2022-07-05 17:15:34,904: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,905: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/ssl.py", line 1309, in do_handshake

[2022-07-05 17:15:34,906: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,907: WARNING/ForkPoolWorker-2] self._sslobj.do_handshake()
[2022-07-05 17:15:34,907: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,908: WARNING/ForkPoolWorker-2] urllib3.exceptions
[2022-07-05 17:15:34,908: WARNING/ForkPoolWorker-2] .
[2022-07-05 17:15:34,908: WARNING/ForkPoolWorker-2] ProtocolError
[2022-07-05 17:15:34,909: WARNING/ForkPoolWorker-2] : 
[2022-07-05 17:15:34,909: WARNING/ForkPoolWorker-2] ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
[2022-07-05 17:15:34,910: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,910: WARNING/ForkPoolWorker-2] 
During handling of the above exception, another exception occurred:


[2022-07-05 17:15:34,910: WARNING/ForkPoolWorker-2] Traceback (most recent call last):

[2022-07-05 17:15:34,911: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner

[2022-07-05 17:15:34,913: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,913: WARNING/ForkPoolWorker-2] self.run()
[2022-07-05 17:15:34,914: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,914: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/threading.py", line 892, in run

[2022-07-05 17:15:34,915: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,916: WARNING/ForkPoolWorker-2] self._target(*self._args, **self._kwargs)
[2022-07-05 17:15:34,916: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,916: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/firebase_admin/db.py", line 128, in _start_listen

[2022-07-05 17:15:34,918: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,918: WARNING/ForkPoolWorker-2] self._callback(Event(sse_event))
[2022-07-05 17:15:34,918: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,919: WARNING/ForkPoolWorker-2]   File "/app/tele/tg_bot_live/tasks.py", line 158, in related_balls_stream_handler

[2022-07-05 17:15:34,920: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,920: WARNING/ForkPoolWorker-2] telegram_send_message(bot_token=stream_channel_bot_token,
[2022-07-05 17:15:34,921: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,921: WARNING/ForkPoolWorker-2]   File "/app/tele/tele_utils/factories.py", line 23, in telegram_send_message

[2022-07-05 17:15:34,922: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,922: WARNING/ForkPoolWorker-2] r = requests.post(
[2022-07-05 17:15:34,922: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,923: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 117, in post

[2022-07-05 17:15:34,924: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,925: WARNING/ForkPoolWorker-2] return request('post', url, data=data, json=json, **kwargs)
[2022-07-05 17:15:34,926: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,926: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request

[2022-07-05 17:15:34,927: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,927: WARNING/ForkPoolWorker-2] return session.request(method=method, url=url, **kwargs)
[2022-07-05 17:15:34,928: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,928: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request

[2022-07-05 17:15:34,930: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,930: WARNING/ForkPoolWorker-2] resp = self.send(prep, **send_kwargs)
[2022-07-05 17:15:34,931: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,932: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send

[2022-07-05 17:15:34,932: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,933: WARNING/ForkPoolWorker-2] r = adapter.send(request, **kwargs)
[2022-07-05 17:15:34,934: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,934: WARNING/ForkPoolWorker-2]   File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 498, in send

[2022-07-05 17:15:34,935: WARNING/ForkPoolWorker-2]     
[2022-07-05 17:15:34,936: WARNING/ForkPoolWorker-2] raise ConnectionError(err, request=request)
[2022-07-05 17:15:34,936: WARNING/ForkPoolWorker-2] 

[2022-07-05 17:15:34,937: WARNING/ForkPoolWorker-2] requests.exceptions
[2022-07-05 17:15:34,937: WARNING/ForkPoolWorker-2] .
[2022-07-05 17:15:34,937: WARNING/ForkPoolWorker-2] ConnectionError
[2022-07-05 17:15:34,938: WARNING/ForkPoolWorker-2] : 
[2022-07-05 17:15:34,938: WARNING/ForkPoolWorker-2] ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer