selenium-plugin icon indicating copy to clipboard operation
selenium-plugin copied to clipboard

Getting `Could not connect to port 4444 on host` `Could not get IP address for host` error

Open patcadelina opened this issue 7 years ago • 2 comments

My Jenkins and nodes are setup in AWS as EC2 instances. Jenkins host lives in the same VPC as the nodes although they live in separate subnets. The way the security groups are configured is that nodes connect to a load balancer listening on http://custom.url:4444 which then forwards traffic to the Jenkins host. The Jenkins host is allowed to do health checks on the node using their internal IP on port 4444. Additionally, an entry to /etc/hosts file had to be added on Jenkins master so that nodes are able to register to this custom URL.

0.0.0.0 custom.url

Using this configuration, I'm able to successfully register nodes as reported both on UI and from logs. However, when I try to submit a selenium job to the grid, I get the above errors. Happens on both Chrome and Firefox browsers.

I point the tests to the custom URL in my Jenkinsfile as pybot --variable LOCALHOST:http://custom.url:4444/wd/hub src/.

Relevant logs from log.html:

FAIL 	No browser is open 	
DEBUG 	Traceback (most recent call last):
  File "<decorator-gen-147>", line 2, in capture_page_screenshot
  File "/usr/local/lib/python2.7/site-packages/Selenium2Library/keywords/keywordgroup.py", line 15, in _run_on_failure_decorator
    return method(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/Selenium2Library/keywords/_screenshot.py", line 90, in capture_page_screenshot
    if hasattr(self._current_browser(), 'get_screenshot_as_file'):
  File "/usr/local/lib/python2.7/site-packages/Selenium2Library/keywords/_browsermanagement.py", line 516, in _current_browser
    raise RuntimeError('No browser is open')

INFO 	Opening browser 'firefox' to base url 'https://<redacted>' through remote server at 'http://custom.url:4444/wd/hub' 	
INFO 	Could not connect to port 4444 on host custom.url
INFO 	Could not get IP address for host: custom.url

Environment: hub: Ubuntu nodes: Windows packages installed on the nodes:

> choco list --local-only 
Chocolatey v0.10.11
chocolatey 0.10.11
chocolatey-core.extension 1.3.3
chromedriver 2.410
curl 7.61.1
Firefox 62.0
git 2.19.0
git.install 2.19.0
GoogleChrome 69.0.3497.9200
javaruntime 8.0.151
jdk8 8.0.181
jre8 8.0.181
python2 2.7.15
selenium-chrome-driver 2.41
13 packages installed.

patcadelina avatar Sep 25 '18 04:09 patcadelina

it looks like the following issue https://github.com/SeleniumHQ/selenium/issues/2913 where like an assumption: "Most likely you have changed your /etc/hosts file to a domain or something else from the default 'localhost'."

dmitryyu avatar Sep 26 '18 19:09 dmitryyu

Thanks for the reply @dmitryyu.

I've made some changes in the infrastructure by bypassing traffic to the load balancer all together. Now, the nodes are able to connect with the hub and vice-versa on port 4444. To test if that works, I ran curl from one of the nodes which is successful.

+ curl -I http://<redacted>:4444
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
HTTP/1.1 200 OK
Date: Tue, 02 Oct 2018 10:45:35 GMT
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked
Server: Jetty(9.4.7.v20170914)

Now to make the setup cleaner, I made a DNS record to point custom.url directly to the hub's private IP. Re-checked with curl.

+ curl -I http://custom.url:4444
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
HTTP/1.1 200 OK
Date: Tue, 02 Oct 2018 10:45:35 GMT
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked
Server: Jetty(9.4.7.v20170914)

I then updated the Selenium Plugin settings to accept node registration from custom.url and my job to point LOCALHOST to http://custom.url:4444 which again regenerated the issue.

patcadelina avatar Oct 03 '18 03:10 patcadelina