4

I have a Selenium Grid up and running on an AWS EC2 instance. I would like to connect to this from my local machine using Java to fire off my tests via a RemoteWebDriver, however, I'm unable to connect to the server be it through SSH or the Public IP.

For example I need to access the instance on port 4444 for a url of http://123.456.78.910:4444/wd/hub this would then need to establish a connection and receive my tests.

Whenever I try to use the Public IP I simply get a time-out.

Any help would be greatly appreciated.

Smoeey
  • 127
  • 3
  • 11

4 Answers4

3

You are getting a time out because your port 4444 is blocked in the EC2 security group. Check below you have add that rule to you EC2 security group. You can either add 0.0.0.0/0 but I will suggest just add your IP as you will be the only one to access that port from your local and for better security.

enter image description here

Piyush Patil
  • 14,512
  • 6
  • 35
  • 54
  • 1
    Thank you for your help. I tried this with both my ip and all but it is still refusing the connection saying that it has timed out. These are my settings: http://i.imgur.com/28s1Ghl.jpg – Smoeey Aug 03 '16 at 14:33
  • 1
    Add another rule there http tcp 80 0.0.0.0/0 – Piyush Patil Aug 03 '16 at 14:36
  • Try accessing the console from your home or outside your company network. if you can access it, then it might be your company's proxy/firewall preventing you from accessing that URL. – Ramesh Oct 15 '20 at 14:43
0

When you start a selenium grid hub - you are shown a message such as : register node to the hub: http://{hub-ip}:4444/grid/register

When i tried to register a node with hub-ip , it did not work for me. so i checked the public-ip of my ec2 instance by logging in to the ec2 console.

then i registered the node with http://{public-ip}:4444/grid/register it worked.

so use public ip of ec2 instance to register the node. the hub-ip duggested by selenium grid did not work for me on ec2

if i place hub , node on local machine - then none of this problem occurs.

are you running node and hub on different ec2 instances ? You should also add the remotehost option while starting a node from an instance different from the hub instance to tell the hub about your ip address.

java -Dwebdriv.gecko.driver="geckodriver" -jar selenium-server-standalone-3.13.0.jar -role node -hub http://{hub-public-ip}:4444/grid/register/ -remoteHost "http://{node-public-ip}" public ip of script instance - 34.224.113.203

mrtechmaker
  • 1,769
  • 12
  • 11
  • thanks for the above, may you provide further information on public IP of script instance - 34.224.113.203. Does this mean the IP of the Selenium client? – Tinashe Chinyanga Jul 29 '21 at 08:46
  • @TinasheChinyanga yes , check the public ip of your machine => the hub, node .i guess i have just added an example ip address of my hub. add hub ip , node ip i guess hub is the server , node is the client. sorry i had worked on this long time back. ec2 console has public ip if you are using aws. all the best. selenium also has irc chat for support where you can ask questions. – mrtechmaker Aug 03 '21 at 11:16
0

I had the same problem with Selenium standalone 3-x. I installed a proxy server (nginx) and did a port forwarding. Then it started working.

skomisa
  • 16,436
  • 7
  • 61
  • 102
0

Do not use the container port directly, instead use the host port which in turn communicate to container port.

For eg: docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED                                                                                                     STATUS              PORTS                     NAMES
"container id"       selenium/hub        "/opt/bin/entry_poinâ¦"   23 hours ago                                                                                                Up About an hour    0.0.0.0:32768->4444/tcp   hub

Here use the port 32768 instead of 4444

T. Short
  • 3,481
  • 14
  • 30
Anubhav
  • 23
  • 1
  • 3