ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

前端 未结 6 785
时光说笑
时光说笑 2020-11-28 13:29

For some reason I get the following error only when I open up a nested webdriver instance. No idea what is happening here.

I a

相关标签:
6条回答
  • 2020-11-28 13:55

    As documentation says:

    Software caused connection abort. An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error.

    Possible reasons:

    1. Timeout or other network-level error.
    2. Network connection died
    3. Firewall closed the connection because it was open too long
    4. Connection was closed before process has been finished
    5. AntiVirus blocks the connection

    and etc.

    Also try to downgrade geckodriver 0.21.0 to geckodriver 0.20.1. You can download it here. It seems to be a problem with geckodriver 0.21.0 https://stackoverflow.com/a/51236719/8625512

    PS:

    options.add_argument('-headless')
    

    should be:

    options.add_argument('--headless')
    
    0 讨论(0)
  • 2020-11-28 14:00

    This problem happened to me and as the error was intermittent, I initially believed that it was some firewall or antivirus problem, but it was much simpler.

    I had a form that was being submitted twice when the SEND button was clicked. The button was set to type="submit" and a javascript code submitted this form when this button was clicked. I changed the button to type="button" and the problem was solved.

    0 讨论(0)
  • 2020-11-28 14:04

    I solved this problem with a browser configuration in Firefox: Go to Settings -> general and scroll down to network configuration. in the window that opens I go to the end I selected DNS PROXY USE SOCKS and activated DNS over HTTPS. I chose all three options available.

    0 讨论(0)
  • 2020-11-28 14:05

    This error message...

    ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
    

    ...implies that the initialization of a new WebBrowsing Session i.e. Firefox Browser session was aborted.


    An established connection was aborted by the software in your host machine

    As per your code attempt the error is clearly coming out create_webdriver_instance() function which contains:

    try:
        ua_string = random.choice(ua_strings)
        profile = webdriver.FirefoxProfile()
        profile.set_preference('general.useragent.override', ua_string)
        return webdriver.Firefox(profile)
    

    And:

    except IndexError as error:
        print('\nSection: Function to Create Instances of WebDriver\nCulprit: random.choice(ua_strings)\nIndexError: {}\n'.format(error))
        return webdriver.Firefox()
    

    So it is not exactly clear from which function you are facing this issue among return webdriver.Firefox(profile) or webdriver.Firefox().

    Perhaps a closer look at the logs within codepen suggests the error is coming out from webdriver.Firefox(profile).


    Reasons

    There can be multiple reason behind this error:

    • Presence of anti-virus softwares.
    • Firewall blocking the ports.
    • Network Configuration.
    • Problem can be caused by CORS.
    • Due to enabling of HTTP keep-alive connections

    Solution

    The initial step would be find out if any software is blocking the connection to/from the server in your computer. Apart from that the probable solutions are:

    • Disable anti-virus softwares.
    • Disable firewall.
    • Ensure that /etc/hosts on your system contains the following entry:

      127.0.0.1   localhost.localdomain localhost
      
    • As per Connection was aborted by the software in your host machine you need to allow localhost routes like http://localhost:8080/reactive-commands

    • As per Keep-Alive connection to geckodriver 0.21.0 dropped after 5s of inactivity without re-connection using Selenium Python client

      • AutomatedTester: This issue is not because we are not connected at the time of doing a request. If that was the issue we would be getting a httplib.HTTPConnection exception being thrown. Instead a BadStatusLine is thrown when we do a connection and close it and try parse the response. Now this could be the python stdlib bug, httplib bug or selenium bug. A Python client to replace urllib with something else that does not exhibit the same defect with Keep-Alive connections is WIP.

      • andreastt: The geckodriver team is working on extending the server-side timeout value to something more reasonable. As I said, this would help mitigate this issue but not fundamentally fix it. In any case it is true that five seconds is probably too low to get real benefit from persistent HTTP connections, and that increasing it to something like 60 seconds would have greater performance.


    Conclusion

    Selenium 3.14.0 has just been released. If you are affected by this issue please upgrade accordingly.


    References:

    • Flask broken pipe with requests
    • Cross-Origin Resource Sharing (CORS)
    • Connection was aborted by the software in your host machine
    • [WinError 10053] with the 0.21.0
    • Keep-Alive connection to geckodriver 0.21.0 dropped after 5s of inactivity without re-connection using Selenium Python client
    • Support keep alive connections
    • Struct hyper::server::Server
    • Urllib3
    0 讨论(0)
  • 2020-11-28 14:17

    Another reason: When a page served by python is loading ,user may cancel the loading before tranmission is complete,by pressing Esc or by clicking 'X'(Stop loading this page button).This is usually done when the server is slow. Eg if user goes to 1 and Press Esc before the image is fully loaded,this error will occur.In that case,you have to Handle it.

    0 讨论(0)
  • 2020-11-28 14:19

    Windows has implemented Controlled folder access, which is to block un-authorized app to access your important files(means almost anything installed by windows). This is to prevent data encryption and ransom by malware.

    Windows will pop-out notification if it blocks any app.

    You can allow apps/programs access through Controlled folder access.

    0 讨论(0)
提交回复
热议问题