简体   繁体   English

无法连接到在 AWS EC2 上运行的 Selenium Grid

[英]Unable to connect to Selenium Grid running on AWS EC2

I have a Selenium Grid up and running on an AWS EC2 instance.我在 AWS EC2 实例上启动并运行了 Selenium Grid。 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.我想使用 Java 从我的本地机器连接到它,以通过 RemoteWebDriver 启动我的测试,但是,我无法通过 SSH 或公共 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.例如,我需要访问端口4444上的实例以获取http://123.456.78.910:4444/wd/hub的 URL,然后需要建立连接并接收我的测试。

Whenever I try to use the Public IP I simply get a time-out.每当我尝试使用公共 IP 时,我都会超时。

Any help would be greatly appreciated.任何帮助将不胜感激。

You are getting a time out because your port 4444 is blocked in the EC2 security group.您超时了,因为您的端口 4444 在 EC2 安全组中被阻止。 Check below you have add that rule to you EC2 security group.在下面检查您是否已将该规则添加到您的 EC2 安全组。 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.您可以添加 0.0.0.0/0 但我建议只添加您的 IP,因为您将是唯一一个从本地访问该端口并提高安全性的人。

在此处输入图片说明

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当您启动 selenium 网格集线器时 - 您会看到一条消息,例如:将节点注册到集线器:http://{hub-ip}:4444/grid/register

When i tried to register a node with hub-ip , it did not work for me.当我尝试使用 hub-ip 注册节点时,它对我不起作用。 so i checked the public-ip of my ec2 instance by logging in to the ec2 console.所以我通过登录到 ec2 控制台检查了我的 ec2 实例的公共 IP。

then i registered the node with http://{public-ip}:4444/grid/register it worked.然后我用 http://{public-ip}:4444/grid/register 注册了节点,它工作了。

so use public ip of ec2 instance to register the node.所以使用ec2实例的公共ip来注册节点。 the hub-ip duggested by selenium grid did not work for me on ec2 selenium grid 挖掘的 hub-ip 在 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 ?您是否在不同的 ec2 实例上运行节点和集线器? 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.您还应该在从不同于集线器实例的实例启动节点时添加remotehost选项,以告诉集线器您的 IP 地址。

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 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}" 脚本实例的公共 ip - 34.224.113.203

I had the same problem with Selenium standalone 3-x.我在 Selenium Standalone 3-x 上遇到了同样的问题。 I installed a proxy server (nginx) and did a port forwarding.我安装了一个代理服务器(nginx)并进行了端口转发。 Then it started working.然后它开始工作。

Do not use the container port directly, instead use the host port which in turn communicate to container port.不要直接使用容器端口,而是使用主机端口,主机端口依次与容器端口通信。

For eg: docker ps例如: 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这里使用端口32768而不是4444

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM