I have a Python (3.5) script that uses Selenium (3.12), chromedriver (2.39) and Google Chrome (67) on a headless Debian (9) server.
The Python is installed in a virtualenv.
About 50% of the time the script runs without fault. The other 50% I get the following errors. Is this just a plain ol' bug in chrome/chromedriver (both latest versions direct from Google) or is it likely anything to do with my setup/code?
My code is pretty standard:
options = webdriver.ChromeOptions()
options.add_argument('headless')
options.binary_location='/usr/bin/google-chrome-stable'
options.add_argument('window-size={}x{}'.format(*self.window_size))
self.driver = webdriver.Chrome(chrome_options=options)
Error message:
File "./grab-regulars.py", line 25, in __init__
self.driver = webdriver.Chrome(chrome_options=options)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
desired_capabilities=desired_capabilities)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
self.start_session(capabilities, browser_profile)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 245, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
response = self.command_executor.execute(driver_command, params)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/remote/remote_connection.py", line 472, in execute
return self._request(command_info[0], url, body=data)
File "cwd/env/lib/python3.5/site-packages/selenium/webdriver/remote/remote_connection.py", line 496, in _request
resp = self._conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1198, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.5/socket.py", line 576, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer