0esr的504网关超时错误

0esr的504网关超时错误

本文介绍了使用GeckoDriver Selenium和Python在无头模式下使用Firefox 68.9.0esr的504网关超时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用硒制作了一个容器图像.我使用RedHat的 ubi图像作为基本图像.

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

  • 壁虎驱动程序0.26.0(e9783a644016 2019-10-10 13:38 +0000)
  • Mozilla Firefox 68.9.0esr

我可以在firefox上成功进行硒测试.当我进行无头测试时,出了点问题:

  Traceback(最近一次通话最近):< module>中的文件"./selenium-test.py",第58行.check_browser("FIREFOX")在check_browser中的文件"./selenium-test.py",第26行driver.get("http://selenium-hub-cpet-selenium.apps.idc.ont.belastingdienst.nl/grid/console")在get中的文件"/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",第333行self.execute(Command.GET,{'url':url})执行中的文件"/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",第321行self.error_handler.check_response(响应)在check_response中的文件"/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py",第208行引发exception_class(value)selenium.common.exceptions.WebDriverException:消息:< html>< body>< h1> 504网关超时</h1>服务器没有及时响应.</body></html> 

运行容器的OpenShift日志:

  09:54:45.599信息[ActiveSessionFactory.lambda $ apply $ 11]-匹配的工厂org.openqa.selenium.grid.session.remote.ServicedSession $ Factory(提供者:org.openqa.selenium.firefox.GeckoDriverService)无法打开与会话"的连接.消息总线:地址不包含冒号1593770085639 mozrunner :: runner INFO运行命令:"/usr/bin/firefox"牵线木偶"无头"-前景"禁止远程"个人资料""/tmp/rust_mozprofileaaKtFi"1593770085639 geckodriver :: marionette DEBUG等待60年代在127.0.0.1:34835上连接到浏览器无法打开与会话"的连接.消息总线:地址不包含冒号在没有任何支持的情况下运行!***您正在以无头模式运行.1593770086616 [email protected]警告正在加载扩展"[email protected]":阅读清单:无效的扩展许可权:mozillaAddons1593770086616 [email protected]警告加载扩展名"[email protected]":阅读清单:无效的扩展名许可:遥测1593770086616 [email protected]警告加载扩展名"[email protected]":阅读清单:无效的扩展名许可:resource://pdf.js/1593770086616 [email protected]警告正在加载扩展名"[email protected]":正在读取清单:无效的扩展名许可:about:reader *1593770086749 Marionette TRACE收到观察者通知,变更后配置文件1593770086826 Marionette TRACE收到观察者通知命令行启动1593770086826 Marionette TRACE已收到观察员通知nsPref:已更改1593770086826牵线木马DEBUG初始化中止(正在运行= false,enabled = true,finalUIStartup = false)1593770086938 Marionette TRACE已收到观察者通知,顶层窗口已准备就绪JavaScript错误:未定义,第14行:错误:发生意外错误JavaScript错误:moz-extension://b2c6e410-fc73-460e-9587-3e165c5ce4ac/lib/picture_in_picture_overrides.js,第15行:错误:pictureInPictureParent.setOverrides的参数类型不正确.JavaScript错误:resource:///modules/sessionstore/SessionStore.jsm,第1325行:未捕获的异常:21477460651593770096320 Marionette TRACE收到观察员通知,要求启动木偶1593770096320 Marionette TRACE等待,直到启动记录器完成对启动脚本的记录...1593770096523 Marionette TRACE记录了所有脚本.1593770096524牵线木马DEBUG将建议的prep apz.content_response_timeout设置为600001593770096524牵线木马调试将推荐的pref browser.contentblocking.intro计数设置为991593770096525 Marionette DEBUG设置建议的首选浏览器.download.panel.showd为true1593770096609 Marionette DEBUG设置建议的pref browser.newtabpage.enabled设置为false1593770096610 Marionette DEBUG设置建议的pref browser.pagethumbnails.capturing_disabled为true1593770096611 Marionette DEBUG设置建议的pref browser.search.update为false1593770096611牵线木马调试将推荐的pref browser.tabs.disableBackgroundZombification设置为false1593770096611木偶调试将推荐的pref browser.tabs.remote.separatePrivilegedContentProcess设置为false1593770096612木偶调试将推荐的pref browser.tabs.unloadOnLowMemory设置为false1593770096612牵线木马调试将推荐的pref browser.tabs.warnOnCloseOtherTabs设置为false1593770096612 Marionette DEBUG设置建议的pref browser.tabs.warnOnOpen设置为false1593770096612 Marionette DEBUG设置建议的首选浏览器.usedOnWindows10.introURL到1593770096612牵线木马调试将推荐的pref browser.urlbar.suggest.searches设置为false1593770096613 Marionette DEBUG设置建议的pref datareporting.policy.dataSubmissionPolicy建议为false1593770096613 Marionette DEBUG设置建议的pref dom.disable_beforeunload设置为true1593770096613牵线木马DEBUG将建议的pref dom.disable_open_during_load设置为false1593770096613 Marionette DEBUG将建议的pref dom.file.createInChild设置为true1593770096613牵线木马调试将建议的首选dom.max_chrome_script_run_time设置为01593770096613 Marionette DEBUG将建议的pred dom.max_script_run_time设置为01593770096614木偶调试将建议的pref extensions.getAddons.cache.enabled设置为false1593770096614木偶调试将推荐的pref extensions.webservice.discoverURL设置为http://%(server)s/dummy/discoveryURL1593770096614 Marionette DEBUG设置推荐的首选网络.http.prompt-temp-redirect为false1593770096614 Marionette DEBUG设置推荐的首选网络.http.speculative-parallel-limit为01593770096614木偶调试将建议的pref security.fileuri.strict_origin_policy设置为false1593770096614木偶调试设置建议的首选安全性.notification_enable_delay为01593770096614木偶调试将推荐的pref signon.autofillForms设置为false1593770096615 Marionette DEBUG设置推荐的pref signon.rememberSignons为false1593770096615牵线木马调试将推荐的pref toolkit.cosmeticAnimations.enabled设置为false1593770096821木偶信息在端口34835上侦听1593770096821 Marionette DEBUG远程服务处于活动状态1593770096914 Marionette DEBUG从127.0.0.1:47282接受的连接01593770096915 geckodriver :: marionette调试在127.0.0.1:34835上建立的与Marionette的连接.1593770096921木偶DEBUG 0->[0,1,"WebDriver:NewSession",{"acceptInsecureCerts":true,"browserName":"firefox"}]]1593770096922此会话将忽略木偶警告" TLS证书错误1593770097114 Marionette TRACE [4294967297]框架脚本已加载1593770097117 Marionette TRACE [4294967297]已注册框架脚本1593770097210牵线木马DEBUG 0  

我尝试了官方的硒图像,该图像使用Mozilla 75版和相同的Geckodriver.他们利用仿生仿生.

这些gecko驱动程序不支持Mozilla Firefox 68.9.0esr吗?还是可能由于无头模式不起作用的另一个原因?

解决方案

此错误消息...

  selenium.common.exceptions.WebDriverException:消息:< html>< body>< h1> 504网关超时</h1>服务器没有及时响应. 

...表示 Firefox v68.9.0esr 无法与应用程序服务器建立连接,并引发了以下WebDriverException错误.


504网关超时错误尚无定论,因为它们表明您的网站发生了什么,但它们并没有传达出确切的错误,因此很难分析根本原因并解决问题.但是,错误 504网关超时 和解决该问题的几种方法如下:

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

此用例

但是从此用例开始,此错误消息...

  1593770085639 geckodriver :: marionette DEBUG等待60年代在127.0.0.1:34835上连接到浏览器无法打开与会话"的连接.消息总线:地址不包含冒号在没有任何支持的情况下运行! 

...表示 Firefox v68.9.0esr 版本存在问题.


解决方案

根据评论在讨论(firefox:28877):GConf-WARNING **:客户端无法连接到D-BUS守护程序:地址不包含冒号,解决方案是还原到 Firefox ESR 构建的先前版本./p>

I made a container image with selenium. I used a ubi image from RedHat as base image.

I installed the following versions of the geckodriver and Mozilla Firefox

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

I can run a selenium test on firefox successfully. When I run a headless test, something goes wrong:

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>

Logs from OpenShift where the container runs:

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   [email protected]     WARN    Loading extension '[email protected]': Reading manifest: Invalid extension permission: mozillaAddons
1593770086616   [email protected]     WARN    Loading extension '[email protected]': Reading manifest: Invalid extension permission: telemetry
1593770086616   [email protected]     WARN    Loading extension '[email protected]': Reading manifest: Invalid extension permission: resource://pdf.js/
1593770086616   [email protected]     WARN    Loading extension '[email protected]': 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

I tried the official selenium image, which uses Mozilla version 75 and the same Geckodriver. They make use of ubuntu bionic.

Is Mozilla Firefox 68.9.0esr not supported with these gecko drivers? Or could it be because of another reason that headless mode doesn't work?

解决方案

This error message...

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

...implies that the Firefox v68.9.0esr was unable to establish a connection with the application server and the following WebDriverException error was raised.


504 Gateway Timeout errors are inconclusive as they indicate what happened to your website, but they doesn't convey what exactly went wrong, making it difficult to analyze the root cause and solve the issue. However, there can be many reasons behind the error 504 Gateway Time-out and a couple of approaches to solve the issue are as follows:

  • Look for server connectivity issues: Check if the server is down for maintenance or any other reason, your website could serve visitors a 504 Gateway Timeout Error page. The only way to troubleshoot this issue is to wait for your server to finish maintenance or fix the problem causing the error.
  • Check for any DNS changes: If the application have recently changed host servers or moved the website to a different IP address website’s DNS server is changed, it could cause your website to serve its visitors a 504 Gateway Timeout Error page. Then the website won't be up and running until the DNS changes take full effect, which can take a couple of hours.
  • Browse through the logs: Logs will provide details about the server’s behavior and status. Analyze them to uncover any useful information.
  • Fix faulty firewall configurations: Firewall is a website's gatekeeper, protecting your site from malicious visitors or distributed denial-of-service (DDoS) attacks. A faulty firewall configuration will cause your firewall to deem requests from a content delivery network as an attack on your server and reject them, resulting in a 504 Gateway Timeout error. Check your firewall configuration to pinpoint and fix the issue.

This usecase

However as of this usecase, this error message...

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!

...indicates that there was an issue with the Firefox v68.9.0esr build.


Solution

As per the comment within the discussion (firefox:28877): GConf-WARNING **: Client failed to connect to the D-BUS daemon: Address does not contain a colon the solution is to revert back to the previous version of Firefox ESR build.

这篇关于使用GeckoDriver Selenium和Python在无头模式下使用Firefox 68.9.0esr的504网关超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 17:22