Getting 'error: [Errno 111] Connection refused' from time to time, although browser is open and connected to the website-under-test

2,683 views
Skip to first unread message

Zeevik Neuman

unread,
Nov 4, 2016, 5:43:40 PM11/4/16
to robotframework-users
Hi.

From time to time my tests fail with the error "error: [Errno 111] Connection refused" (example full stacktrace below)
It happens "randomly" although the browser is open, and the website was already loaded.
Running it again "solves" the issue, until the next time it happens.

Sounds like an issue with the selenium driver unable to connect to the browser or its data ??
Any pointers/directions how to debug that would be appreciated.

Thanks,
Zeevik


Keyword 'Capture Page Screenshot' could not be run on failure: error: [Errno 111] Connection refused
14:09:29.637INFO/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:787: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning) Traceback (most recent call last): File "./resources/baseUI.py", line 73, in _open_login_page self.driver.go_to(self._getenvurl()) File "<decorator-gen-36>", line 2, in go_to File "/usr/local/lib/python2.7/dist-packages/Selenium2Library/keywords/keywordgroup.py", line 15, in _run_on_failure_decorator return method(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/Selenium2Library/keywords/_browsermanagement.py", line 410, in go_to self._current_browser().get(url) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 213, in get self.execute(Command.GET, {'url': url}) File "/usr/local/lib/python2.7/dist-packages/Selenium2Library/webdrivermonkeypatches.py", line 11, in execute result = self._base_execute(driver_command, params) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 199, in execute response = self.command_executor.execute(driver_command, params) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 395, in execute return self._request(command_info[0], url, body=data) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 425, in _request self._conn.request(method, parsed_url.path, body, headers) File "/usr/lib/python2.7/httplib.py", line 1052, in request self._send_request(method, url, body, headers) File "/usr/lib/python2.7/httplib.py", line 1092, in _send_request self.endheaders(body) File "/usr/lib/python2.7/httplib.py", line 1048, in endheaders self._send_output(message_body) File "/usr/lib/python2.7/httplib.py", line 892, in _send_output self.send(msg) File "/usr/lib/python2.7/httplib.py", line 854, in send self.connect() File "/usr/lib/python2.7/httplib.py", line 831, in connect self.timeout, self.source_address) File "/usr/lib/python2.7/socket.py", line 575, in create_connection raise err error: [Errno 111] Connection refused

Tatu Aalto

unread,
Nov 7, 2016, 2:34:05 AM11/7/16
to zee...@zeevik.net, robotframework-users

Ugh

Unfortunately browsers and the underlying technology is not bullet proof. Also I see similar errors perhaps once and twice a month (when I run 10-12 hours of test in a day). But if your ratio is bigger, then there might be something else wrong in your set up.

I see from the stack trace that the error happens when the browser is trying to navigate to the URL. But that doesn't, unfortunately, help us much. To help you better could you please tell, when you encounter the problem, is it always exactly the same error? Does it always happen with the same keyword? What browser and version you are using and have you tried with different browser and/or version? What version of Selenium2Library, selenium and Python you are using? Also if you are using other browser than Firefox, could you tell the driver version too.

-Tatu
Send from my mobile


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Zeevik Neuman

unread,
Nov 7, 2016, 11:41:48 AM11/7/16
to Tatu Aalto, robotframework-users
Hi.

Thanks for your response.

The ratio is definitely higher that 1-2/mo.

Using firefox version 'Mozilla Firefox 45.0'
python -m robot --version = Robot Framework 3.0 (Python 2.7.10 on linux2)

Yes it is always when the browser navigates for the first time.
The website opens as expected, but I'm still getting connection refused  error and test fails

Below is the full method of _open_login_page. 
Pretty straight forward (unless I'm missing something).

Any help/direction will be appreciated.
Zeevik

This is the full method:
    def _open_login_page(self):
        try:
            self.driver.go_to(self._getenvurl())
            self.sleep(1)
        except Exception as e:
            self.warn("Got excpeption {0} trying to open the login page".format(e))
            traceback.print_exc()
        self.driver.wait_until_page_contains_element("//div//input[@name='email']", 10)


To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsubscrib...@googlegroups.com.

To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Tatu Aalto

unread,
Nov 7, 2016, 12:51:50 PM11/7/16
to Zeevik Neuman, robotframework-users

Ugh

The code looks OK. Did you try with another browser, like Chrome, to rule out that this is a Firefox specific problem? Also have you tried with different selenium versions? Also, is there a display, virtual or real one, where the browser runs?

-Tatu
Send from my mobile

Zeevik Neuman

unread,
Nov 7, 2016, 2:00:13 PM11/7/16
to Tatu Aalto, robotframework-users
Did not fully try Chrome yet, so cannot rule out a Firefox specific issue
There is a real display, and in all cases, the display shows the expected screen opened, so I cannot really figure out what connection was refused, as the page was fully loaded....

Will keep digging.
Zeevik

Tatu Aalto

unread,
Nov 8, 2016, 10:01:30 AM11/8/16
to Zeevik Neuman, robotframework-users

Ugh

Perhaps looking selenium architecture[1] explains the problem better. The selenium Python client uses the json wire protocol to talk to driver. The driver could be a separate executable, like the chrome driver or like in Firefox (version 47 or older) a extension. The selenium Python client talks to the driver by using http and the error you see, is caused by a failure in that http interface. It's not caused by the browser not reaching the destination url. Why the failure happens is a good question and I don't have answer for it. The most elegant solution I have found, is to try with different browser, selenium and driver version and stick with the combination that works. And also allow updates to happen only in a controlled manner.

-Tatu
Send from my mobile

[1] http://seleniumtutorialpoint.com/2015/01/webdriver-architecture/

Reply all
Reply to author
Forward
0 new messages