kyb3r / dhooks

A simple python Discord webhook API wrapper
https://discord.gg/etJNHCQ
MIT License
189 stars 50 forks source link

When two seperate scripts try and send an embed at around the same time, one of the two hits this error 'An existing connection was forcibly closed by the remote host' #53

Open caynebrister opened 2 years ago

caynebrister commented 2 years ago

I have 2 separate scripts each sending embeds to different web hook URLS, when I run them individually I get no issues, but when I run both at the same time after a while I hit the following error on either one out of the two scripts, seemingly when they both try to send an embed using their respective web hook URL around the same time: "ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)"

Configuration details:

Error segment that contains this message (note, this segment is the only one that directly references my original code, and it specifically references the line where I try and send the embed, this has lead me to believe it has to do with dhooks and not selenium, which is what I originally thought was my issue):

Traceback (most recent call last): File "C:\Users\User\Documents\python\waifu\new_waifus.py", line 113, in hook.send(embed=embed) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\dhooks\client.py", line 275, in send return self._request('POST', payload, file=file) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\dhooks\client.py", line 359, in _request resp = self.session.post(self.url, json=payload, File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 635, in post return self.request("POST", url, data=data, json=json, kwargs) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 587, in request resp = self.send(prep, send_kwargs) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 701, in send r = adapter.send(request, **kwargs) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\requests\adapters.py", line 547, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

Entire error message:

Traceback (most recent call last): File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\urllib3\connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\urllib3\connectionpool.py", line 449, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\urllib3\connectionpool.py", line 444, in _make_request httplib_response = conn.getresponse() File "C:\Program Files\Python39\lib\http\client.py", line 1377, in getresponse response.begin() File "C:\Program Files\Python39\lib\http\client.py", line 320, in begin version, status, reason = self._read_status() File "C:\Program Files\Python39\lib\http\client.py", line 281, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "C:\Program Files\Python39\lib\socket.py", line 704, in readinto return self._sock.recv_into(b) File "C:\Program Files\Python39\lib\ssl.py", line 1242, in recv_into return self.read(nbytes, buffer) File "C:\Program Files\Python39\lib\ssl.py", line 1100, in read return self._sslobj.read(len, buffer) 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\User\AppData\Roaming\Python\Python39\site-packages\requests\adapters.py", line 489, in send resp = conn.urlopen( File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\urllib3\connectionpool.py", line 787, in urlopen retries = retries.increment( File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\urllib3\util\retry.py", line 550, in increment raise six.reraise(type(error), error, _stacktrace) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\urllib3\packages\six.py", line 769, in reraise raise value.with_traceback(tb) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\urllib3\connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\urllib3\connectionpool.py", line 449, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\urllib3\connectionpool.py", line 444, in _make_request httplib_response = conn.getresponse() File "C:\Program Files\Python39\lib\http\client.py", line 1377, in getresponse response.begin() File "C:\Program Files\Python39\lib\http\client.py", line 320, in begin version, status, reason = self._read_status() File "C:\Program Files\Python39\lib\http\client.py", line 281, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "C:\Program Files\Python39\lib\socket.py", line 704, in readinto return self._sock.recv_into(b) File "C:\Program Files\Python39\lib\ssl.py", line 1242, in recv_into return self.read(nbytes, buffer) File "C:\Program Files\Python39\lib\ssl.py", line 1100, in read return self._sslobj.read(len, buffer) urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\User\Documents\python\waifu\new_waifus.py", line 113, in hook.send(embed=embed) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\dhooks\client.py", line 275, in send return self._request('POST', payload, file=file) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\dhooks\client.py", line 359, in _request resp = self.session.post(self.url, json=payload, File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 635, in post return self.request("POST", url, data=data, json=json, kwargs) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 587, in request resp = self.send(prep, send_kwargs) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 701, in send r = adapter.send(request, **kwargs) File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\requests\adapters.py", line 547, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

caynebrister commented 2 years ago

If anyone knows how I can fix this I would appreciate the help, I have been trying to figure this out almost all day. Also if anyone would like to see the code for both the python programs, let me know and I would gladly send both. I didn't start by sending them because nearly all the code in the project isn't related to dhooks and the program works flawlessly every time when they both aren't run simultaneously.