Selenium Grid无法管理专用网络中的节点

时间:2017-07-24 09:14:35

标签: selenium selenium-grid

  1. 服务器端

    我们的Selenium Grid服务器具有公共IP地址(104.131.xxx.xxx)

    java -jar selenium-server-standalone-3.4.0.jar -role hub
    
  2. 节点

    专用网络中有节点计算机(192.168.43.xxx)。他们能够毫无问题地连接到Selenium Server:

    java -jar selenium-server-standalone-3.4.0.jar -role webdriver -hub http://104.131.xxx.xxx:4444/grid/register -port 3456
    
  3. Selenium Grid Console

    1. 问题

      3.1服务器上有重复的消息:

      Registered a node http://192.168.43.248:3456
      Marking the node http://192.168.43.248:3456 as down: cannot reach the node for 2 tries
      Unregistering the node http://192.168.43.248:3456 because it's been down for 60060 milliseconds
      Cleaning up stale test sessions on the unregistered node http://192.168.43.248:3456
      
      Registered a node http://192.168.43.248:3456
      Marking the node http://192.168.43.248:3456 as down: cannot reach the node for 2 tries
      ......
      

      3.2我们无法开始任何测试。当我们尝试开始时,我们得到了:

      Got a request to create a new session: Capabilities [{marionette=true, loadImages=false, acceptInsecureCerts=true, browserName=firefox}]
      Trying to create a new session on test slot {seleniumProtocol=WebDriver, browserName=firefox, maxInstances=5, platform=WIN10}
      Marking the node http://192.168.43.248:3456 as down: cannot reach the node for 2 tries
      Unregistering the node http://192.168.43.248:3456 because it's been down for 60050 milliseconds
      Cleaning up stale test sessions on the unregistered node http://192.168.43.248:3456
      Removed a session that had not yet assigned an external key f83395be-cb27-43a3-8999-b5573f387715, indicates failure in session creation PROXY_REREGISTRATION
      Registered a node http://192.168.43.248:3456
      Marking the node http://192.168.43.248:3456 as down: cannot reach the node for 2 tries
      

      3.3测试的痕迹:

      selenium.common.exceptions.WebDriverException: Message: Error forwarding the new session Error forwarding the request Connect to 192.168.43.248:3456 [/192.168.43.248] failed: Connection timed out (Connection timed out)
      
    2. 我们应该创建VPN-network还是Selenium Grid有一些特殊的方法来管理这个问题?

      P.S。当我们将Selenium Server移动到本地环境时,一切正常。

1 个答案:

答案 0 :(得分:3)

主要问题不在于节点无法向集线器注册,但问题在于集线器的ping(Hub始终以预定的时间间隔向节点发送心跳信号,以检查节点是否已启动或如果他们失败了)没有到达节点。我猜这可能是因为Hub和节点在不同的网络上,所以双向通信没有发生。

这与我在Amazon Cloud计算机上运行Selenium Hub并将其暴露给外部世界,然后尝试在我的本地计算机(也具有Internet连接)上生成Selenium节点并尝试连接这个节点到Hub。

从节点到集线器的注册将起作用,因为我的机器(节点在其上运行)能够发现在云上运行的集线器(并且暴露在外面),但是当集线器尝试发送心跳信号时到我的节点,尝试失败,因为我的机器已发送它的内部IP地址,该地址仅在本地网络中可见,但不在外部,这是集线器用于发送心跳信号的IP地址。

这更像是一个网络问题,与Selenium Grid没有任何关系。

最重要的是,您需要确保Selenium Hub和Selenium Node都在同一网络上。所以你可以通过VPN配置完成它(我不是网络专家,因此我不能就此做出更多评论)(或)你将你的Hub移动到与你的节点相同的网络。

希望增加清晰度。