Python remote client does not implement read timeouts
Problem description:
When a WebDriver instance makes a remote command request, and the server accepts the connection and reads the request but does not write a response, then the client continues waiting indefinitely for a response.
Expected results:
The WebDriver client raises some kind of TimeOut exception after sending a request and not receiving a response within some predefined time period.
Actual results:
The WebDriver client blocks indefinitely (or until the connection is terminated, etc).
Steps to reproduce:
- Listen on port 4444 with netcat:
nc -l 4444 - Use Python client to issue a webdriver command:
python -c 'from selenium.webdriver.remote.webdriver import WebDriver; WebDriver("http://127.0.0.1:4444/wd/hub", {})' - Observe that the client blocks and never times out
I found that as of release 2.46.0 I'm able to set a global socket timeout via RemoteConnection.set_timeout(), thanks to (thanks to 08882053):
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.remote.remote_connection import RemoteConnection
RemoteConnection.set_timeout(5)
WebDriver("http://127.0.0.1:4444/wd/hub", {})
With this configuration, if the server fails to respond within the timeout, a socket.timeout exception is raised.
closing as that's the recommend approach for this issue :)