Hi, The connection I am making is not going through a proxy, but directly to the device over https.
Like I said in the original post, it works most of the time, but not always and it I can't reproduce the error on-demand. In this line: html_content = return_object.read(), will it read binary data or is that only applicable when I write it to a file to write it as binary? Any help would be appreciated. Thanks Johan From: nehal dattani [mailto:[email protected]] Sent: Friday, 7 October 2011 7:49 PM To: Johan Geldenhuys Subject: Re: [Tutor] urllib2 sslerror Hi Johan, If you are using http proxy, this may be helpful. http://stackoverflow.com/questions/1030113/does-urllib2-in-python-2-6-1-supp ort-proxy-via-https Regards, Nehal Dattani On Fri, Oct 7, 2011 at 11:14 AM, Johan Geldenhuys <[email protected]> wrote: Hi everybody, Almost weekend, hang in there. I need some advice and hope somebody can help me. I have the follow piece of code that I use to get some data from a https webpage. ------------------------------------------------------- < some other stuff up here> try: return_object = urllib2.urlopen(theurl) html_content = return_object.read() now = time.strftime("%Y%m%d%H%M%S") img_file = "%s_%s.jpg"% (location, now) f = open(img_file, 'wb') f.write(html_content) f.close() file = img_file except Exception, e: print e <some other stuff down here> ------------------------------------------------------- Sometimes I get the following error and I don't know why. It occurs very randomly and is hard or nearly impossible to reproduce (maybe there is somebody who knows how to create it). ------------------------------------------------------- Traceback (most recent call last): File "/var/ai-muse/jail/pkgdb/camimage/getimage.py", line 74, in run return_object = urllib2.urlopen(self.theurl) File "/usr/lib/python2.2/urllib2.py", line 138, in urlopen File "/usr/lib/python2.2/urllib2.py", line 322, in open File "/usr/lib/python2.2/urllib2.py", line 301, in _call_chain File "/usr/lib/python2.2/urllib2.py", line 792, in https_open File "/usr/lib/python2.2/urllib2.py", line 779, in do_open File "/usr/lib/python2.2/urllib2.py", line 342, in error File "/usr/lib/python2.2/urllib2.py", line 301, in _call_chain File "/usr/lib/python2.2/urllib2.py", line 611, in http_error_401 File "/usr/lib/python2.2/urllib2.py", line 590, in http_error_auth_reqed File "/usr/lib/python2.2/urllib2.py", line 600, in retry_http_basic_auth File "/usr/lib/python2.2/urllib2.py", line 322, in open File "/usr/lib/python2.2/urllib2.py", line 301, in _call_chain File "/usr/lib/python2.2/urllib2.py", line 792, in https_open File "/usr/lib/python2.2/urllib2.py", line 774, in do_open File "/usr/lib/python2.2/httplib.py", line 752, in getreply File "/usr/lib/python2.2/httplib.py", line 593, in getresponse File "/usr/lib/python2.2/httplib.py", line 99, in __init__ File "/usr/lib/python2.2/httplib.py", line 628, in makefile sslerror: (5, 'EOF occurred in violation of protocol') ------------------------------------------------------------ Any idea why it happens randomly and how I can check the cause? I read on a Google search page that one guy had the same issue and traced it back to some characters in the data he was receiving. Could that cause it? Thanks in advance Johan _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
