amazon-web-servicesdockernetwork-programmingamazon-ec2selenium-grid

Selenium hub fails to register docker selenium nodes on a remote machine


I set up the hub and a node on two different Linux EC2 instances. Set up the hub with below command,

$ docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.141.0

Set up the node and connect it to the hub with below command.

$ docker run -d -p 5555:5555 -e REMOTE_HOST="http://<Node-IP>:5555" -e HUB_PORT_4444_TCP_ADDR="<Hub-IP>" -e HUB_PORT_4444_TCP_PORT="4444" --name chrome-node selenium/node-chrome:3.141.0

Even though the logs of the node machine mentions, it's successfully connected to the hub, the hub machine gives the following logs

04:06:01.912 INFO [DefaultGridRegistry.add] - Registered a node http://172.17.0.6:5555
04:06:18.054 INFO [DefaultRemoteProxy.onEvent] - Marking the node http://172.17.0.6:5555 as down: cannot reach the node for 2 tries
04:06:38.502 INFO [DefaultRemoteProxy.onEvent] - Unregistering the node http://172.17.0.6:5555 because it's been down for 64512 milliseconds

The IP address of the node machine mentioned in those logs is not the I publish from the docker command. How do I make the hub know the exact IP of the node machine?

I tried to look for the docker command to publish the exact Node IP address. But could not find any forum that discusses it.


Solution

  • Using below commands for Hub and Nodes work correctly.

    Hub :

    $ docker run -d -p 4442-4444:4442-4444 --name selenium-hub selenium/hub:4.9.1-20230508
    

    Node :

    $ docker run -d -p 5555:5555 \
        --shm-size="2g" \
        -e SE_EVENT_BUS_HOST=<ip-of-hub-machine> \
        -e SE_EVENT_BUS_PUBLISH_PORT=4442 \
        -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
        -e SE_NODE_HOST=<ip-of-node-machine> \
        selenium/node-chrome:4.9.1-20230508
    

    for more information refer : https://github.com/SeleniumHQ/docker-selenium