1

I'm looking to get more information about IOError: [Errno socket error] [Errno 10060] when using urlopen in Python 2.7. I am using my personal 35MB/s Internet connection (no proxy).

I've been opening multiple webpages from various websites using a Python script and randomly get this error message from time to time:

webpage = urlopen('http://www.thewebpage.com')


IOError: [Errno socket error] [Errno 10060] A connection attempt
failed because the connected party did not properly respond after a
period of time, or established connection failed because connected
host has failed to respond

This error appeared after trying to open pages from different websites. Therefore, it doesn't seem to be related exclusively to the opening of pages from one particular website. I also got this error using mechanize.

My questions are :

  1. Is this error related to the fact that I am sending multiple requests to the same server within a short amount of time? Would a time-out reduces the chance of getting this error?
  2. Is there any way to prevent it? Could I use a conditional statement to prevent the script from crashing?

My script takes around an hour to run and having to rerun it due to this error is fairly unpleasant.

LaGuille
  • 1,658
  • 5
  • 20
  • 37
  • 1
    Can you access the website in question through other means? (say, with `curl`?) – icktoofay Apr 11 '14 at 05:50
  • I haven't try `curl`. I am just curious about the fact that for the same URL, I would get this error on a certain day and not on another day. It arises approximately once every 2000 times I open a URL. My script was built for a web scraping purpose. – LaGuille Apr 11 '14 at 05:56
  • @LaGuille Can you please provide exact url ? – Nishant Nawarkhede Apr 11 '14 at 06:04
  • Like mentioned in the question, I've been getting this error message while opening pages from **various** websites. This is not related to a URL in particular. I was just looking to get more info about what might have been causing the error and if there was any way to avoid it since it seems to occur randomly. – LaGuille Apr 11 '14 at 06:07

1 Answers1

3

Sending multiple requests to the same server in short succession could very well cause the server not to respond, since your requests might look like a ddos attack. You can catch the exception with a try-except clause, and try again.

Thayne
  • 6,619
  • 2
  • 42
  • 67