Docker-selenium: Unable to set -remoteHost parameter for nodes without using custom config.json

Created on 30 Mar 2015  路  11Comments  路  Source: SeleniumHQ/docker-selenium

Hi,

I've got this setup on separate hosts. So one host runs the HUB, and then several other hosts have nodes running on them. In this use case, I am unable to link containers, so I need to expose ports, and public IPs of hosts running nodes in order to connect to the HUB. Below is the example command that we use to start a node (replace 1.2.3.4 with IP of hub):

docker run -d -p 5555:5555 -e HUB_PORT_4444_TCP_ADDR="1.2.3.4" -e HUB_PORT_4444_TCP_PORT="4444" --name firefox-node selenium/node-firefox

What ends up happening, is the value for remoteHost gets set to the 'private' IP of the docker container itself. If you exec into a running docker container, and execute ipconfig, you'll see the IP that it uses. This is fine if you are 'linked' to the hub, but when running on separate hosts, the hub cannot contact the private IP. To enable this to work, we need support for -remoteHost parameter when starting the nodes.

-remoteHost is a built in parameter for selenium. More info available here: http://automatictester.co.uk/2012/10/27/selenium-grid-2-0-and-remotehost-parameter/

After this feature is implemented, we should be able to run nodes like this (notice the addition of the REMOTE_HOST env variable):

docker run -d -p 5555:5555 -e REMOTE_HOST="http://1.2.3.4:5555" -e HUB_PORT_4444_TCP_ADDR="1.2.3.4" -e HUB_PORT_4444_TCP_PORT="4444" --name firefox-node selenium/node-firefox

NOTE: In example above, you would need to provide correct IP for REMOTE_HOST and HUB, not the 1.2.3.4 that I provided as an example.

enhancement

Most helpful comment

I am trying to run docker Selenium on diff hosts (2 Linux machines)

using these commands on Hub and on node

docker run -p 4444:4444 -d -P --name selenium-hub selenium/hub

docker run -d -p 5558:5556 -e SE_OPTS="-host 10.20.50.53 -port 5558" -e HUB_PORT_4444_TCP_ADDR="10.20.50.92" -e HUB_PORT_4444_TCP_PORT="4444" --name firefox selenium/node-firefox

How ever,I see the that the node is registered , but when i fire a test the request says pending
Here are the Hub logs and screenshot

12:26:43.302 INFO - Unregistering the node http://10.20.50.53:5558 because it's been down for 60014 milliseconds
12:26:43.302 WARN - Cleaning up stale test sessions on the unregistered node http://10.20.50.53:5558
12:26:43.389 INFO - Registered a node http://10.20.50.53:5558
12:27:03.395 INFO - Marking the node http://10.20.50.53:5558 as down: cannot reach the node for 2 tries

image

The Node seems to be up and running. Not sure what can be the issue

Could any one please help me on this.

All 11 comments

Great PR - I hope this gets pulled in!

+1 for merging. I tested it out locally and it works great.

I am trying to connect the "docker selenium remote node" to "remote docker hub", But it's not connecting, It shows the connection refused exception, Even I can connect my "remote node" to "docker hub". please help me. and my commands are here.
Hub:
docker run -d -p 4444:4444 --name my_hub selenium/hub:2.47.1
Node:
docker run -d -p 5558:5555 -e REMOTE_HOST="http://172.21.113.202:4444" -e HUB_PORT_4444_TCP_ADDR="172.21.113.202" -e HUB_PORT_4444_TCP_PORT="4444" --name firefox selenium/node-firefox:2.47.1

The following screen shot explains the clear exception
screen shot 2015-10-12 at 10 56 58 am

@viveksoundarrajan it looks like your docker run command is routing the port 5558 to 5555(inside container), with the -p 5558:5555 parameter. This means your REMOTE_HOST parameter should be using the the same port (5558). This parameter tells the hub how it can reach the node over network, so it should be configured to match the IP of the docker host running your node, and the port 5558. Also, in your run parameter it looks like you're using the IP of your hub for the REMOTE_HOST. The remote host is not your hub, that is the node itself, and is sent to the hub to let it know how to reach the node. The REMOTE_HOST parameter should include the IP that your node is running on.

Hi @charford, it looks like the -remoteHost parameter no longer works on Docker images with Selenium Grid v3.0.0 (selenium-server-standalone.jar). See #306 and #307 for exact error. Any idea what might have changed between 2.53.1 and 3.0.0?

I wonder if it has anything to do with the command line argument parser change that was made for v3. https://github.com/SeleniumHQ/selenium/issues/2566

As far as I can see, the remoteHost parameter continues to be supported - https://github.com/SeleniumHQ/selenium/blob/master/java/server/src/org/openqa/grid/internal/utils/configuration/GridNodeConfiguration.java

@testphreak I haven't had a chance to try this in the latest (3.0) version. But the SE_OPTS solution mentioned in #307 looks promising.

@charford figured it out finally :).

SE_OPTS="-host $HOSTNAME"

I am trying to run docker Selenium on diff hosts (2 Linux machines)

using these commands on Hub and on node

docker run -p 4444:4444 -d -P --name selenium-hub selenium/hub

docker run -d -p 5558:5556 -e SE_OPTS="-host 10.20.50.53 -port 5558" -e HUB_PORT_4444_TCP_ADDR="10.20.50.92" -e HUB_PORT_4444_TCP_PORT="4444" --name firefox selenium/node-firefox

How ever,I see the that the node is registered , but when i fire a test the request says pending
Here are the Hub logs and screenshot

12:26:43.302 INFO - Unregistering the node http://10.20.50.53:5558 because it's been down for 60014 milliseconds
12:26:43.302 WARN - Cleaning up stale test sessions on the unregistered node http://10.20.50.53:5558
12:26:43.389 INFO - Registered a node http://10.20.50.53:5558
12:27:03.395 INFO - Marking the node http://10.20.50.53:5558 as down: cannot reach the node for 2 tries

image

The Node seems to be up and running. Not sure what can be the issue

Could any one please help me on this.

@lukeis This is happening on selenium standalone version3.3.1 . Nodes are continuously getting reconnected to hub.
Can some one please take look at it?

@yatheeshAtzenq This is happaning because the SE_OPTS option does not exactly the same as the good old REMOTE_HOST option did. Instead it overwrites the nodes port and ip setting.
So while your port mapping thinks the node uses 5556, the node itsself uses 5558. And that's why the hub can't reach it.

--> #481

Was this page helpful?
0 / 5 - 0 ratings