You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在selenium/standalone-firefox容器中R Selenium连接服务器失败求助

解决方案

1. 修正remoteDriver连接参数

容器内运行Firefox通常需要无头模式配置,且无需手动指定版本(容器内Selenium与Firefox版本已配套),尝试调整代码如下:

remDr <- remoteDriver(
  remoteServerAddr = "localhost",
  port = 4444L,
  browserName = "firefox",
  extraCapabilities = list(
    "moz:firefoxOptions" = list(
      args = list("--headless", "--no-sandbox", "--disable-dev-shm-usage")
    )
  )
)

remDr$open()

2. 验证Selenium服务状态

在容器内执行命令,确认Selenium服务正常响应:

curl http://localhost:4444/wd/hub/status

返回结果中包含"ready": true则说明服务运行正常;若无响应,需检查容器内Selenium服务的启动日志排查问题。

3. 避免rsDriver的冲突

容器内已运行Selenium服务,而rsDriver会尝试启动本地新的Selenium服务,因此确实无法使用该方式连接,必须通过remoteDriver直接对接已运行的服务。

4. 检查容器网络配置

若容器通过自定义网络或Docker Compose启动,确保R进程所在环境能访问到Selenium服务的4444端口;独立运行的容器内部直接使用localhost即可访问服务。


内容的提问来源于stack exchange,提问作者M-C

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 14:52:04