Selenium Grid 无法管理私有网络中的节点

use*_*709 2 selenium selenium-grid

  1. 服务器端

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

    java -jar selenium-server-standalone-3.4.0.jar -role hub
    
    Run Code Online (Sandbox Code Playgroud)
  2. 节点

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

    java -jar selenium-server-standalone-3.4.0.jar -role webdriver -hub http://104.131.xxx.xxx:4444/grid/register -port 3456
    
    Run Code Online (Sandbox Code Playgroud)

Selenium 网格控制台

  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
    ......
    
    Run Code Online (Sandbox Code Playgroud)

    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
    
    Run Code Online (Sandbox Code Playgroud)

    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)
    
    Run Code Online (Sandbox Code Playgroud)

我们应该创建 VPN-network 还是 Selenium Grid 有一些特殊的方法来管理这个问题?

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

Kri*_*van 6

主要问题不在于节点无法向集线器注册自己,而是问题在于集线器的 ping(集线器以预定的时间间隔不断向节点发送心跳信号以检查节点是否已启动或它们是否已启动) down) 没有到达节点。我猜这可能是因为集线器和节点位于不同的网络上,因此两种方式的通信没有发生。

这与我在 Amazon Cloud 机器上运行 Selenium Hub 并将其暴露给外部世界,然后尝试在我的本地机器(也具有互联网连接)上生成一个 Selenium 节点并尝试在该节点中连接到集线器。

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

这更像是一个网络问题,与 Selenium Grid 无关。

最重要的是,您需要确保您的 Selenium 集线器和 Selenium 节点在同一网络上。因此,您可以通过 VPN 配置来完成它(我不是网络专家,所以我不能就如何做到这一点发表更多评论)(或者)将您的集线器移动到与节点相同的网络。

希望能增加清晰度。