4

I started messing around with Python networking using selenium on Firefox. Unfortunately, I keep getting "ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine".

However, this only happens when running some commands, and it only happens the first time I run them. If execute the command a second time right after that, it works. (See below for a minimal example.)

I found this question, but being a networking newbie I'm having a hard time applying the solution to my situation. How do I prevent the connection from shutting down?

Any help is greatly appreciated!

from selenium import webdriver

browser = webdriver.Firefox()
browser.get('http://www.google.com/')

searchfield = browser.find_element_by_id("lst-ib")  # Runs without issues
searchfield.get_attribute("value")  # Produces WinError 10053
searchfield.get_attribute("value")  # Returns '' as it should

EDIT: It seems the error only occurs, when I execute the command in the shell, rather than saving and running the whole script. Nonetheless, it's pretty annoying.

Michael
  • 79
  • 1
  • 8
  • what version of `geckodriver` do you have? this similar bug https://github.com/mozilla/geckodriver/issues/713 suggests upgrading to `0.21.0` release of geckodriver if you don't have it already. – chickity china chinese chicken Jun 23 '18 at 00:23
  • I downloaded it yesterday, so it's probably as up to date as it can be. I tried to reproduce the error mentioned in the link, but it threw me a different one (WinError 10061). – Michael Jun 23 '18 at 02:11
  • Not sure why getting different messages, that one related to not getting any connection [WinError 10061 - No Connection Could be made](https://stackoverflow.com/questions/20437701/winerror-10061-no-connection-could-be-made) – chickity china chinese chicken Jun 23 '18 at 03:59

2 Answers2

11

I got the same problem, my config is: Firefox 60.0.2 (64 bits) ; geckodriver 0.21.0 ( 64 bits) ; selenium 3.12.0

I resolved this problem by downgrade geckodriver to 0.20.1 ( 64 bits)

Yohan
  • 124
  • 1
  • 5
  • 2
    Saved my day! I was misled by https://github.com/mozilla/geckodriver/issues/713 into thinking geckodriver 0.21.0 is the one to use. – Big Pumpkin Jun 26 '18 at 23:34
  • Can confirm, this seems to have fixed the problem for me. With 21.0 I could get a URL immediately after opening a browser, but a subsequent call to get() would inevitably fail with a 10053 error. I could usually then get() more times successfully, but every now and then I'd get another 10053. Downgrading to 0.20.1 has alleviated the symptom as described. – Darren Ringer Jul 25 '18 at 16:14
0

I had the same problem and tried solutions that were mentioned here but nothing helped me. In the end, it was a very simple solution:

copy the script and the geckodriver to a different folder, and then run it from there. I suppose that in the folder where I always worked I had logs that generated conflicts and that's why this solution worked.

ozo
  • 883
  • 1
  • 10
  • 18