【问题标题】:Selenium node Digital Ocean through ssh Xvfb - does not attempt to connect to hubSelenium 节点 Digital Ocean 通过 ssh Xvfb - 不尝试连接到集线器
【发布时间】:2026-01-10 04:30:02
【问题描述】:

尝试在 Ubuntu 14 上通过带有 xvfb 的 ssh 在无头数字海洋机器上运行 selenium 节点。安装了所有软件包,chromium-browser 在 xvfb 上正确启动。

它的行为很奇怪:没有错误,但根本没有尝试连接集线器。而是仅启动 Jetty。

确切的命令行:

xvfb-run -a --server-args="-screen 0 1920x1280x24" java -Djava.net.preferIPv4Stack=true -jar selenium-server-standalone-2.48.2.jar -role node -Dwebdriver.chrome.driver=./chromedriver -hub "http://localhost:4444/grid/register" -browser "browserName=chrome, platform=LINUX, maxInstances=5, chrome.binary=/usr/bin/chromium-browser"

在我的本地 PC 上,节点尝试连接到集线器,而在无头数字海洋上没有任何反应,集线器没有在 /grid/console 页面上列出节点。 唯一的线索是节点日志的最后几行不同。

无头数字海洋:

11:55:53.483 INFO - Version Jetty/5.1.x
11:55:53.484 INFO - Started HttpContext[/selenium-server,/selenium-server]

我的电脑:

17:52:04.859 INFO - Selenium Grid node is up and ready to register to the hub
17:52:04.877 INFO - Starting auto registration thread. Will try to register every 5000 ms.
17:52:04.877 INFO - Registering the node to the hub: http://46.101.128.117:4444/grid/register
17:52:04.936 INFO - The node is registered to the hub and ready to use

有什么想法可能是错的吗?有没有人用类似的设置成功过?


Digital Ocean 的完整日志无头:

11:55:52.753 INFO - Launching a Selenium Grid node
11:55:52.820 INFO - Adding browserName=chrome, platform=LINUX, maxInstances=5, chrome.binary=/usr/bin/chromium-browser
Setting system property webdriver.chrome.driver to ./chromedriver
11:55:53.347 INFO - Java: Oracle Corporation 25.45-b02
11:55:53.348 INFO - OS: Linux 3.19.0-22-generic amd64
11:55:53.354 INFO - v2.48.0, with Core v2.48.0. Built from revision 41bccdd
11:55:53.433 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
11:55:53.434 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
11:55:53.434 INFO - Driver class not found: com.opera.core.systems.OperaDriver
11:55:53.435 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
11:55:53.483 INFO - Version Jetty/5.1.x
11:55:53.484 INFO - Started HttpContext[/selenium-server,/selenium-server]

在我的 PC 上运行的相同示例给出:

17:52:04.341 INFO - Launching a Selenium Grid node
17:52:04.387 INFO - Adding browserName=chrome, platform=LINUX, maxInstances=5, chrome.binary=/usr/bin/chromium-browser
Setting system property webdriver.chrome.driver to ./chromedriver
17:52:04.750 INFO - Java: Oracle Corporation 25.45-b02
17:52:04.750 INFO - OS: Linux 3.19.0-30-generic amd64
17:52:04.754 INFO - v2.48.0, with Core v2.48.0. Built from revision 41bccdd
17:52:04.816 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
17:52:04.817 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
17:52:04.818 INFO - Driver class not found: com.opera.core.systems.OperaDriver
17:52:04.818 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
17:52:04.859 INFO - Selenium Grid node is up and ready to register to the hub
17:52:04.877 INFO - Starting auto registration thread. Will try to register every 5000 ms.
17:52:04.877 INFO - Registering the node to the hub: http://46.101.128.117:4444/grid/register
17:52:04.936 INFO - The node is registered to the hub and ready to use

【问题讨论】:

    标签: selenium ssh selenium-grid digital-ocean


    【解决方案1】:

    我有办法。

    已经在Selenium stand alone server hang while starting中描述了。

    根本原因:数字海洋机器有一些弱熵,所以需要使用额外的软件工具。

    如果 selenium 检测到这一点并显示一些消息而不是挂起会很好。

    【讨论】:

    • 在文章之后:*.com/questions/27216816/… 为我解决了这个问题。我在数字海洋之外的 RHEL7 机器上遇到了类似的问题。
    【解决方案2】:

    如果您在 Linux 上的虚拟机或无头服务器(包括 Digital Ocean 虚拟机)中运行 selenium 节点,您可能会遇到此问题。这是因为您的虚拟机/服务器没有足够的可用熵。

    要解决这个问题,只需安装haveged(或其他类似的东西)。

    要在 CentOS 7 上安装它,你需要启用 EPEL,然后运行:

    yum install haveged
    systemctl enable haveged
    systemctl start haveged
    

    对于其他 Linux 发行版,请参阅:https://www.digitalocean.com/community/tutorials/how-to-setup-additional-entropy-for-cloud-servers-using-haveged

    【讨论】: