Skip to content

[🐛 Bug]: Connection timeout with webdriver.Chrome at the start of script #15538

Open
@moises902

Description

@moises902

What happened?

Running into a timeout issue with starting a python selenium chrome script and trying to get to at least 'about:blank'. The browser opens up 'data:,' and just hangs up. Afterwards, an error stack trace will show up. The same script works fine if we use MS edge however, we can only run the script using Chrome per company server rules.

How can we reproduce the issue?

1. Run script

`from selenium import webdriver

print('----Start of Script----')
options = webdriver.ChromeOptions()
service = webdriver.ChromeService(executable_path='chromedriver.exe',service_args=['--log-level=DEBUG'], log_output='chromedriver.log')

options.add_argument("--disable-gpu")
options.add_argument("--no-sandbox")

# Initialize the Chrome WebDriver
print('----Options Created----')
driver = webdriver.Chrome(service=service)
print('----driver loaded----')

# Open a blank page
driver.get('about:blank')
driver .quit()`

Relevant log output

`F:\App\Pysel\test>python conda_test.py
----Start of Script----
----Options Created----

DevTools listening on ws://xxxxxxx:xxxxxxxx/devtools/browser/17d41e4e-ae41-4dc1-b0cc-6b3246a02b83
Created TensorFlow Lite XNNPACK delegate for CPU.
Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors (tensor#-1 is a dynamic-sized tensor).
Traceback (most recent call last):
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 534, in _make_request
    response = conn.getresponse()
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connection.py", line 516, in getresponse
    httplib_response = super().getresponse()
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\http\client.py", line 1430, in getresponse
    response.begin()
    ~~~~~~~~~~~~~~^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\http\client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ~~~~~~~~~~~~~~~~~^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\http\client.py", line 292, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
               ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\socket.py", line 719, in readinto
    return self._sock.recv_into(b)
           ~~~~~~~~~~~~~~~~~~~~^^^
TimeoutError: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "F:\App\Pysel\test\conda_test.py", line 12, in <module>
    driver = webdriver.Chrome(service=service)
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__
    super().__init__(
    ~~~~~~~~~~~~~~~~^
        browser_name=DesiredCapabilities.CHROME["browserName"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        keep_alive=keep_alive,
        ^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 250, in __init__
    self.start_session(capabilities)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 342, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 427, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 404, in execute
    return self._request(command_info[0], url, body=data)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 428, in _request
    response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout)
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\_request_methods.py", line 143, in request
    return self.request_encode_body(
           ~~~~~~~~~~~~~~~~~~~~~~~~^
        method, url, fields=fields, headers=headers, **urlopen_kw
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\_request_methods.py", line 278, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\poolmanager.py", line 443, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 841, in urlopen
    retries = retries.increment(
        method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
    )
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\util\retry.py", line 474, in increment
    raise reraise(type(error), error, _stacktrace)
          ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\util\util.py", line 39, in reraise
    raise value
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    response = self._make_request(
        conn,
    ...<10 lines>...
        **response_kw,
    )
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 367, in _raise_timeout
    raise ReadTimeoutError(
        self, url, f"Read timed out. (read timeout={timeout_value})"
    ) from err
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=xxxxx): Read timed out. (read timeout=120)`

Operating System

Windows 10

Selenium version

Selenium 4.29.0, Python 3.13.2

What are the browser(s) and version(s) where you see this issue?

Chrome 134.0.6998.36

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 134.0.6998.165

Are you using Selenium Grid?

no

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!C-pyPython BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions