当前位置: 首页 > 知识库问答 >
问题:

504在GeckoDriver Selenium和Python的无头模式下使用Firefox 68.9.0ESR时发生网关超时错误

邵兴文
2023-03-14

我用硒做了一个容器图像。我使用了来自RedHat的UBI Image作为基映像。

我安装了以下版本的geckodriver和Mozilla Firefox

  • Geckodriver 0.26.0(e9783a644016 2019-10-10 13:38+0000)
  • Mozilla Firefox 68.9.0ESR

我可以成功地在firefox上运行一个selenium测试。当我运行无头测试时,会出现问题:

Traceback (most recent call last):
  File "./selenium-test.py", line 58, in <module>
    check_browser("FIREFOX")
  File "./selenium-test.py", line 26, in check_browser
    driver.get("http://selenium-hub-cpet-selenium.apps.idc.ont.belastingdienst.nl/grid/console")
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
    self.execute(Command.GET, {'url': url})
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 208, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: <html><body><h1>504 Gateway Time-out</h1>
The server didn't respond in time.
</body></html>

从运行容器的OpenShift日志

09:54:45.599 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
Failed to open connection to "session" message bus: Address does not contain a colon
1593770085639   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "-marionette" "-headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileaaKtFi"
1593770085639   geckodriver::marionette DEBUG   Waiting 60s to connect to browser on 127.0.0.1:34835
Failed to open connection to "session" message bus: Address does not contain a colon
Running without a11y support!
*** You are running in headless mode.
1593770086616   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
1593770086616   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: telemetry
1593770086616   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1593770086616   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
1593770086749   Marionette      TRACE   Received observer notification profile-after-change
1593770086826   Marionette      TRACE   Received observer notification command-line-startup
1593770086826   Marionette      TRACE   Received observer notification nsPref:changed
1593770086826   Marionette      DEBUG   Init aborted (running=false, enabled=true, finalUIStartup=false)
1593770086938   Marionette      TRACE   Received observer notification toplevel-window-ready
JavaScript error: undefined, line 14: Error: An unexpected error occurred
JavaScript error: moz-extension://b2c6e410-fc73-460e-9587-3e165c5ce4ac/lib/picture_in_picture_overrides.js, line 15: Error: Incorrect argument types for pictureInPictureParent.setOverrides.
JavaScript error: resource:///modules/sessionstore/SessionStore.jsm, line 1325: uncaught exception: 2147746065
1593770096320   Marionette      TRACE   Received observer notification marionette-startup-requested
1593770096320   Marionette      TRACE   Waiting until startup recorder finished recording startup scripts...
1593770096523   Marionette      TRACE   All scripts recorded.
1593770096524   Marionette      DEBUG   Setting recommended pref apz.content_response_timeout to 60000
1593770096524   Marionette      DEBUG   Setting recommended pref browser.contentblocking.introCount to 99
1593770096525   Marionette      DEBUG   Setting recommended pref browser.download.panel.shown to true
1593770096609   Marionette      DEBUG   Setting recommended pref browser.newtabpage.enabled to false
1593770096610   Marionette      DEBUG   Setting recommended pref browser.pagethumbnails.capturing_disabled to true
1593770096611   Marionette      DEBUG   Setting recommended pref browser.search.update to false
1593770096611   Marionette      DEBUG   Setting recommended pref browser.tabs.disableBackgroundZombification to false
1593770096611   Marionette      DEBUG   Setting recommended pref browser.tabs.remote.separatePrivilegedContentProcess to false
1593770096612   Marionette      DEBUG   Setting recommended pref browser.tabs.unloadOnLowMemory to false
1593770096612   Marionette      DEBUG   Setting recommended pref browser.tabs.warnOnCloseOtherTabs to false
1593770096612   Marionette      DEBUG   Setting recommended pref browser.tabs.warnOnOpen to false
1593770096612   Marionette      DEBUG   Setting recommended pref browser.usedOnWindows10.introURL to
1593770096612   Marionette      DEBUG   Setting recommended pref browser.urlbar.suggest.searches to false
1593770096613   Marionette      DEBUG   Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
1593770096613   Marionette      DEBUG   Setting recommended pref dom.disable_beforeunload to true
1593770096613   Marionette      DEBUG   Setting recommended pref dom.disable_open_during_load to false
1593770096613   Marionette      DEBUG   Setting recommended pref dom.file.createInChild to true
1593770096613   Marionette      DEBUG   Setting recommended pref dom.max_chrome_script_run_time to 0
1593770096613   Marionette      DEBUG   Setting recommended pref dom.max_script_run_time to 0
1593770096614   Marionette      DEBUG   Setting recommended pref extensions.getAddons.cache.enabled to false
1593770096614   Marionette      DEBUG   Setting recommended pref extensions.webservice.discoverURL to http://%(server)s/dummy/discoveryURL
1593770096614   Marionette      DEBUG   Setting recommended pref network.http.prompt-temp-redirect to false
1593770096614   Marionette      DEBUG   Setting recommended pref network.http.speculative-parallel-limit to 0
1593770096614   Marionette      DEBUG   Setting recommended pref security.fileuri.strict_origin_policy to false
1593770096614   Marionette      DEBUG   Setting recommended pref security.notification_enable_delay to 0
1593770096614   Marionette      DEBUG   Setting recommended pref signon.autofillForms to false
1593770096615   Marionette      DEBUG   Setting recommended pref signon.rememberSignons to false
1593770096615   Marionette      DEBUG   Setting recommended pref toolkit.cosmeticAnimations.enabled to false
1593770096821   Marionette      INFO    Listening on port 34835
1593770096821   Marionette      DEBUG   Remote service is active
1593770096914   Marionette      DEBUG   Accepted connection 0 from 127.0.0.1:47282
1593770096915   geckodriver::marionette DEBUG   Connection to Marionette established on 127.0.0.1:34835.
1593770096921   Marionette      DEBUG   0 -> [0,1,"WebDriver:NewSession",{"acceptInsecureCerts":true,"browserName":"firefox"}]
1593770096922   Marionette      WARN    TLS certificate errors will be ignored for this session
1593770097114   Marionette      TRACE   [4294967297] Frame script loaded
1593770097117   Marionette      TRACE   [4294967297] Frame script registered
1593770097210   Marionette      DEBUG   0 <- [1,1,null,{"sessionId":"f0d2e302-c592-49a6-bca6-4f597f778385","capabilities":{"browserName":"firefox","browserVersion":"68.9. ... /rust_mozprofileaaKtFi","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true}}]
1593770097214   webdriver::server       DEBUG   <- 200 OK {"value":{"sessionId":"f0d2e302-c592-49a6-bca6-4f597f778385","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"68.9.0","moz:accessibilityChecks":false,"moz:buildID":"20200529103754","moz:geckodriverVersion":"0.26.0","moz:headless":true,"moz:processID":363,"moz:profile":"/tmp/rust_mozprofileaaKtFi","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"linux","platformVersion":"4.18.0-147.8.1.el8_1.x86_64","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}
09:54:57.215 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
09:54:57.216 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session f0d2e302-c592-49a6-bca6-4f597f778385 (org.openqa.selenium.firefox.GeckoDriverService)
1593770102314   webdriver::server       DEBUG   -> POST /session/f0d2e302-c592-49a6-bca6-4f597f778385/url {"url": "http://selenium-hub-cpet-selenium.apps.idc.ont.belastingdienst.nl/grid/console"}
1593770102317   Marionette      DEBUG   0 -> [0,2,"WebDriver:Navigate",{"url":"http://selenium-hub-cpet-selenium.apps.idc.ont.belastingdienst.nl/grid/console"}]
1593770103015   Marionette      TRACE   [4294967297] Received DOM event beforeunload for about:blank

我尝试了官方的selenium映像,它使用Mozilla 75版本和相同的Geckodriver。他们利用ubuntu仿生。

这些gecko驱动程序不支持Mozilla Firefox 68.9.0ESR吗?或者可能是因为另一个原因无头模式不起作用?

共有1个答案

段干高歌
2023-03-14

此错误消息...

selenium.common.exceptions.WebDriverException: Message: <html><body><h1>504 Gateway Time-out</h1>
The server didn't respond in time.

...暗示Firefox V68.9.0ESR无法与应用程序服务器建立连接,并引发以下WebDriverException错误。

504网关超时错误不是结论性的,因为它们表明了您的网站发生了什么,但它们并不能传达出到底是什么出了问题,这使得分析根本原因和解决问题变得困难。然而,错误504网关超时背后可能有许多原因,解决该问题的方法如下:

  • 查找服务器连接问题:检查服务器是否因维护或其他原因而停机,您的网站可能会为访问者提供一个504网关超时错误页面。解决此问题的唯一方法是等待服务器完成维护或修复导致错误的问题。
  • 检查是否有任何DNS更改:如果应用程序最近更改了主机服务器或将网站移动到不同的IP地址,则网站的DNS服务器发生更改,可能会导致您的网站为其访问者提供504网关超时错误页面。则在DNS更改完全生效之前,网站不会启动和运行,这可能需要几个小时。
  • 浏览日志:日志将提供有关服务器行为和状态的详细信息。分析它们以发现任何有用的信息。
  • 修复错误的防火墙配置:防火墙是网站的守门人,保护您的网站免受恶意访问者或分布式拒绝服务(DDoS)攻击。防火墙配置错误将导致防火墙将来自内容传递网络的请求视为对服务器的攻击并拒绝它们,从而导致504网关超时错误。检查防火墙配置以确定并修复问题。

然而,在此使用过程中,此错误消息...

1593770085639   geckodriver::marionette DEBUG   Waiting 60s to connect to browser on 127.0.0.1:34835
Failed to open connection to "session" message bus: Address does not contain a colon
Running without a11y support!

...表示Firefox V68.9.0ESR版本存在问题。

根据讨论中的注释(Firefox:28877):GConf-WARNING**:Client failed to connect to the D-BUS守护进程:Address不包含冒号,解决方案是返回到Firefox ESR Build的以前版本。

 类似资料:
  • 我在一个Spring boot项目中工作,有一个请求返回网关超时504。我可以增加这个超时吗?这是一个属性,我可以改变在独立的完整。xml?我使用的是wildfly服务器。 请求在1分钟内触发两次,每次触发时间为1分钟。

  • 你知道是怎么回事吗?

  • 很多次,当我试图在UI中打开某些DAG的树状视图或任务持续时间页面时,我得到错误:504网关超时。有时在那之后,我甚至无法打开包含DAG列表的页面。你知道这个问题可能来自哪里吗? 运行Airflow的机器的CPU和内存似乎很好,我使用RDS作为元数据。 谢谢!

  • 我使用PHP和Apache以及nginx作为反向代理,所有这些都在Docker上,我有几个长时间运行的调用在60秒后计时,导致504网关超时。我知道我的应用程序被成功调用,因为我正在跟踪我的PHP应用程序的日志,我可以看到它正在积极地向日志写入。每次都是60秒的超时,但我似乎不知道那个设置在哪里。 我尝试了这篇文章中的建议,但没有任何效果。我已经用一些与时间相关的设置更新了php.ini文件,并验

  • 我正在尝试使用Nginx在Ubuntu16.4服务器上托管Django1.11应用程序。但是在运行服务器之后,我得到了 *1从上游读取响应标头时上游超时(110:连接超时),客户端:118.179.95.25,服务器:18.136.204.142,REQU$ 2019/07/24 18:13:13[错误]15221#15221:*1从上游读取响应标头时上游超时(110:连接超时),客户端:118.

  • /etc/httpd/conf.d/fcgid.conf 我有...见下文 我已经尽力做到最好了。为了测试这一点,我只是运行下面的函数。 在与支持人员聊天后,我被告知需要编辑nginx.conf,并被转到以下帖子http://blog.secaserver.com/2011/10/nginx-gateway-time-out/ 在服务器设置中找不到任何值。client_header_timeout