问题
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.
回答1:
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.
回答2:
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
回答3:
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.
回答4:
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
来源:https://stackoverflow.com/questions/38740931/unable-to-connect-to-selenium-grid-running-on-aws-ec2