Urllib2.URLError: handshake failure

I am doing a large http request loop to our database service. Everything works fine, but every time I run it, after a (seemingly random) number of successful requests, I get the following error: urllib2.URLError: <urlopen error [Errno 1] _ssl.c:504: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure> .

I use python, urllib2 to send a request, urllib to encode some things in my url and what it is. As I said, this looks completely random. I just ran it and it failed after 6 requests. Previously, it crashed after 49 successful attempts. Has anyone had this problem before?

thanks

+7
python urllib2
source share
3 answers

It is more connected with the network, not with your code.

I suggest you use a repeat module inside the module.

Or you can add repeat to your code.

For example, you can write like this:

 for i in range(reties): try: resp = xx.get(url) result = resp.get_result except (ConnectionError, SocketError or whatever else): pass else: arise Exception('Retry Error') 
0
source share
Seriously, you should try Python Requests instead of urllib2 if you are not limited to core packages.
-one
source share

Stan I think Scrapy is faster and can handle all types of connection errors.

Eric I suggest you check scrapy , you will be amazed at its speed and functions

Shlomy

-one
source share

All Articles