Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python client has to check for a still active keep-alive connection before sending the command #6072

Closed
whimboo opened this issue Jun 26, 2018 · 5 comments

Comments

@whimboo
Copy link
Contributor

whimboo commented Jun 26, 2018

Meta -

OS: All

Selenium Version: 3.13.0

Browser: Firefox

Browser Version: All versions of Firefox

Since the release of geckodriver version 0.21.0 the keep-alive mode is supported, with the caveat (mozilla/geckodriver#1304) that the timeout on the server side is set to only 5s. As result any command will fail which is send after a time.sleep() larger or equal to 5s. Here an example:

    driver.get("http://example.org")
    time.sleep(6)
    driver.find_element_by_tag_name("h1")

Expected Behavior -

The Selenium client has to check for a valid and active connection before sending the request. It shouldn't result in an exception as shown below.

Actual Behavior -

The next command after the 5s delay will fail with:

../../Users/henrik/.venvs/selenium/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:635: in execute_script
    'args': converted_args})['value']
../../Users/henrik/.venvs/selenium/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:318: in execute
    response = self.command_executor.execute(driver_command, params)
../../Users/henrik/.venvs/selenium/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py:472: in execute
    return self._request(command_info[0], url, body=data)
../../Users/henrik/.venvs/selenium/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py:496: in _request
    resp = self._conn.getresponse()
/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:1136: in getresponse
    response.begin()
/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:453: in begin
    version, status, reason = self._read_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <httplib.HTTPResponse instance at 0x10745d680>

    def _read_status(self):
        # Initialize with Simple-Response defaults
        line = self.fp.readline(_MAXLINE + 1)
        if len(line) > _MAXLINE:
            raise LineTooLong("header line")
        if self.debuglevel > 0:
            print "reply:", repr(line)
        if not line:
            # Presumably, the server closed the connection before
            # sending a valid response.
>           raise BadStatusLine(line)
E           BadStatusLine: ''
@whimboo
Copy link
Contributor Author

whimboo commented Jun 26, 2018

@AutomatedTester can you please have a look? It would be good to also have such a test in the Selenium test suite.

@Ivru
Copy link

Ivru commented Jun 27, 2018

As a workaround, for the moment, I force the webdriver not to use keep_alive connection.
ie :
selenium/webdriver/firefox/webdriver.py line 165
executor = FirefoxRemoteConnection(remote_server_addr=self.service.service_url, keep_alive=False)

@whimboo
Copy link
Contributor Author

whimboo commented Jul 23, 2018

I know that @AutomatedTester rewrote that part of the Python bindings to make use of urllib3, but the patch doesn't seem to have landed yet. David, can you please give us an update?

@lmtierney
Copy link
Member

PR is currently under review #6103

@AutomatedTester
Copy link
Member

as there is a PR no need to keep a bug too

@lock lock bot locked and limited conversation to collaborators Aug 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants