glenn.barker | Hi all, I'm intermittently getting a ConnectionResetError (10054 / "An existing connection was forcibly closed by the remote host") in the middle of my test when running in a CI environment. The app under test is locally-hosted so I don't think it's actually dropping connection, plus screenshots & logging indicate that the app is still functional. Also it's intermittent and only happens in the middle of a test, so not a driver version mismatch either. Once I get the initial ConnectionResetError, then the run is busted until the app and the webdriver instance are totally killed and reset, any other attempts to use any Selenium api results in a NewConnectionError being thrown.
It happens when I do pretty innocuous things within the standard Selenium lib, like simply trying to query driver.window_handles , and the stacktrace indicates that the issue is originating deep within Selenium and urllib3, so I don't think it's my own test code causing this. Any ideas on what could be happening and how to mitigate? Current theory is that maybe the app under test is pegging the CPU or local network connection which causes Selenium to drop the connection but idk if that's actually what's happening or how best to verify that.
Here's an example stacktrace:
Traceback (most recent call last):
File "C:\Users\runneradmin\.virtualenvs\e2e-testing-gceyZJmk\lib\site-packages\urllib3\connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "C:\Users\runneradmin\.virtualenvs\e2e-testing-gceyZJmk\lib\site-packages\urllib3\util\connection.py", line 84, in create_connection
raise err
File "C:\Users\runneradmin\.virtualenvs\e2e-testing-gceyZJmk\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\runneradmin\.virtualenvs\e2e-testing-gceyZJmk\lib\site-packages\urllib3\connectionpool.py", line 677, in urlopen
chunked=chunked,
File "C:\Users\runneradmin\.virtualenvs\e2e-testing-gceyZJmk\lib\site-packages\urllib3\connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\http\client.py", line 1277, in request
self._send_request(method, url, body, headers, encode_chunked)
File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\http\client.py", line 1323, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\http\client.py", line 1272, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\http\client.py", line 1032, in _send_output
self.send(msg)
File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\http\client.py", line 972, in send
self.connect()
File "C:\Users\runneradmin\.virtualenvs\e2e-testing-gceyZJmk\lib\site-packages\urllib3\connection.py", line 187, in connect
conn = self._new_conn()
File "C:\Users\runneradmin\.virtualenvs\e2e-testing-gceyZJmk\lib\site-packages\urllib3\connection.py", line 172, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: urllib3.connection.HTTPConnection object at 0x000001664ED19A48 : Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it | 14:50:40 |