Selenium & Heroku: urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

后端 未结 1 1789
滥情空心
滥情空心 2020-12-03 22:01

Setup:

  • selenium: 3.141.0
  • python: 3.6.7
  • heroku-stack: heroku-18
  • headless-
相关标签:
1条回答
  • 2020-12-03 22:45

    This error message...

    urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
    

    ...implies that the ChromeDriver in Headless mode was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

    Some information regarding the versions of the binaries you are using would have helped us to analyze the error in a better way. However, this issue of urllib3 can be obseved due to several reasons as mentioned below:

    • As you are using non Windows OS, the argument --disable-gpu is not needed as in the discussion Headless: make --disable-gpu flag unnecessary skyos...@chromium.org mentioned:

    This flag is no longer necessary on Linux or macOS. It will become unnecessary on Windows as soon as SwiftShader fails an assert on Windows in headless mode gets fixed.

    • You can find a detailed discussion in Lost UI shared context : while initializing Chrome browser through ChromeDriver in Headless mode

    • Additionally, you can add the argument --disable-dev-shm-usage to overcome limited resource problems:

      chrome_options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
      
    • You can find a detailed discussion on --disable-dev-shm-usage in the discussion org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser

    • As per urllib3.exceptions.ProtocolError: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host')) this issue was observed when there is some incompatibility between the version of the binaries you are using.

    Solution

    • Upgrade ChromeDriver to current ChromeDriver v2.44 level.
    • Keep Chrome version between Chrome v69-71 levels. (as per ChromeDriver v2.44 release notes)
    • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
    • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
    • Take a System Reboot.
    • Execute your @Test.
    0 讨论(0)
提交回复
热议问题