Search code examples
pythonseleniumfirefoxgeckodriversplinter

Connection Refused and Polling for changes failed: NetworkError when attempting to fetch resource error with Selenium GeckoDriver and Firefox


As per the title, now, firefox opens up, seems to do nothing, then disappears!

  1. I've run this before from a local ubuntu 16.04 VM and all was fine.

(Yes, i have upgraded to the latest of selenium etc. as follows: selenium 3.141.0 splinter 0.10.0 six 1.12.0 urllib3 1.25.3) Now, geckodriver.log shows the following:

1559646629845   geckodriver     INFO    Listening on 127.0.0.1:60172  
1559646630836   mozprofile::profile     INFO    Using profile path /tmp/rust_mozprofile.5DqFww40mZ6W  
1559646630851   geckodriver::marionette INFO    Starting browser /usr/bin/firefox  
1559646630857   geckodriver::marionette INFO    Connecting to Marionette on localhost:46681  
1559646631959   [email protected]     WARN    Loading extension '[email protected]': Reading manifest: Invalid extension permission: mozillaAddons  
1559646631960   [email protected]     WARN    Loading extension '[email protected]': Reading manifest: Invalid extension permission: resource://pdf.js/  
1559646631960   [email protected]     WARN    Loading extension '[email protected]': Reading manifest: Invalid extension permission: about:reader*  
1559646637156   Marionette      INFO    Listening on port 2828  
console.error: BroadcastService:  
  receivedBroadcastMessage: handler for  
  remote-settings/monitor_changes  
  threw error:  
  Message: Error: Polling for changes failed: NetworkError when attempting to fetch resource..  
  Stack:  
    remoteSettingsFunction/remoteSettings.pollChanges@resource://services-settings/remote-settings.js:190:13  
JavaScript error: jar:file:///usr/lib/firefox/omni.ja!/components/nsUrlClassifierListManager.js, line 329: NS_ERROR_NOT_INITIALIZED: Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIUrlClassifierDBService.getTables]  
JavaScript error: jar:file:///usr/lib/firefox/omni.ja!/components/nsUrlClassifierListManager.js, line 329: NS_ERROR_NOT_INITIALIZED: Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIUrlClassifierDBService.getTables]  
1559646742440   Marionette      INFO    Stopped listening on port 2828ss  
  1. I've also tried this on a remote ubuntu-16.04 VM (without a GUI ), console shows the same "connection refused" message but this time, geckodriver.log shows a different issue, as follows: (selenium 3.141.0 six 1.12.0 splinter 0.10.0 urllib3 1.25.3)

    1559563047915   geckodriver     INFO    geckodriver 0.18.0  
    1559563047918   geckodriver     INFO    Listening on 127.0.0.1:51758  
    1559563049045   geckodriver::marionette INFO    Starting browser  /usr/bin/firefox with args ["-marionette"]  
    MobaXterm X11 proxy: Unsupported authorisation protocol  
    Failed to connect to Mir: Failed to connect to server socket: No such file or directory  
    Unable to init server: Broadway display type not supported:   localhost:11.0  
    Error: cannot open display: localhost:11.0  
    1559644244502   geckodriver     INFO    geckodriver 0.18.0
    1559644244506   geckodriver     INFO    Listening on 127.0.0.1:53086
    1559644245634   geckodriver::marionette INFO    Starting browser /usr/bin/firefox with args ["-marionette"]
    MobaXterm X11 proxy: Unsupported authorisation protocol
    Failed to connect to Mir: Failed to connect to server socket: No such file or directory
    Unable to init server: Broadway display type not supported: localhost:10.0
    Error: cannot open display: localhost:10.0
    

my test code is :

from splinter import Browser
browser = Browser()
browser.visit( 'https://www.google.com' )
browser.fill( 'q', 'splinter - python acceptance testing     for web application' )
browser.quit()

I appreciate there are similar questions posted to "connection refused" type issues with selenium... I am hoping to find a solution specific to python what seems to me as either a 'network issue' or a 'display issue'...


Solution

  • This error message...

    1559646629845   geckodriver     INFO    Listening on 127.0.0.1:60172  
    1559646630836   mozprofile::profile     INFO    Using profile path /tmp/rust_mozprofile.5DqFww40mZ6W  
    1559646630851   geckodriver::marionette INFO    Starting browser /usr/bin/firefox  
    1559646630857   geckodriver::marionette INFO    Connecting to Marionette on localhost:46681  
    1559646631959   [email protected]     WARN    Loading extension '[email protected]': Reading manifest: Invalid extension permission: mozillaAddons  
    1559646637156   Marionette      INFO    Listening on port 2828  
    console.error: BroadcastService:  
      receivedBroadcastMessage: handler for  
      remote-settings/monitor_changes  
      threw error:  
      Message: Error: Polling for changes failed: NetworkError when attempting to fetch resource..  
      Stack:  
        remoteSettingsFunction/remoteSettings.pollChanges@resource://services-settings/remote-settings.js:190:13  
    JavaScript error: jar:file:///usr/lib/firefox/omni.ja!/components/nsUrlClassifierListManager.js, line 329: NS_ERROR_NOT_INITIALIZED: Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIUrlClassifierDBService.getTables]  
    1559646742440   Marionette      INFO    Stopped listening on port 2828s
    

    ...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowsing Session i.e. Firefox Browser session.

    Your main issue is the incompatibility between the version of the binaries you are using as follows:

    • Your GeckoDriver version geckodriver v0.18.0. (as per first line in second set of logs ...geckodriver INFO geckodriver 0.18.0...)
    • Your Selenium Client version is 3.141.0.
    • Your Firefox version is unknown to us.

    So there is a clear mismatch between the GeckoDriver v0.18.0 Selenium Client v3.141.0.


    Solution

    • Upgrade Selenium to current levels Version 3.141.59.
    • Upgrade GeckoDriver to latest GeckoDriver v0.24.0 level.
    • Ensure GeckoDriver is present in the required location.
    • GeckoDriver is having executable permission for non-root users.
    • Upgrade Firefox to current Firefox v65.0.2 levels.
    • 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.
    • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

    Note: Always maintain the following GeckoDriver, Selenium and Firefox Browser compatibility matrix

    supported_platforms_geckodriver_24

    You can find a relevant detailed discussionin Which Firefox browser versions supported for given Geckodriver version?


    Outro