Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100055
| From | Ulli Horlacher <framstag@rus.uni-stuttgart.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: urllib2.urlopen() crashes on Windows 2008 Server |
| Date | 2015-12-06 09:38 +0000 |
| Organization | University of Stuttgart, FRG |
| Message-ID | <n40vls$4dr$1@news2.informatik.uni-stuttgart.de> (permalink) |
| References | <n3pqq9$6sm$1@news2.informatik.uni-stuttgart.de> <mailman.189.1449191259.14615.python-list@python.org> <n3s2pg$qkp$1@news2.informatik.uni-stuttgart.de> <mailman.203.1449253048.14615.python-list@python.org> |
Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
> >> Connection reset by peer.
> >>
> >> An existing connection was forcibly closed by the remote host.
> >
> >This is not true.
> >The server is under my control. Die client has terminated the connection
> >(or a router between).
> The odds are still good that something on the server is configured to
> not make a clean shutdown of TCP connections (a router should not be
> involved as the TCP connection is from client IP to server IP, regardless
> of intervening MAC Ethernet routing). The RST is coming from the server.
No.
The server does not reset the connection.
It is the router/firewall.
> >How can I trap this within the python program?
> >I see no exception.
>
> It's a socket error
>
> https://docs.python.org/2/library/socket.html
> """
>
> exception socket.error
Ok, I have now:
try:
req = urllib.Request(szurl)
req.add_header('User-Agent',useragent)
u = urllib.urlopen(req)
except urllib.URLError as e:
die('cannot get %s - %s' % (szurl,e.reason))
except urllib.HTTPError as e:
die('cannot get %s - server reply: %d %s' % (szurl,e.code,e.reason))
except (IOError,httplib.BadStatusLine,httplib.HTTPException):
die('cannot get %s - connection reset by router or firewall' % szurl)
except socket.error as msg:
die('cannot get %s - %s' % (szurl,msg))
--
Ullrich Horlacher Server und Virtualisierung
Rechenzentrum IZUS/TIK E-Mail: horlacher@tik.uni-stuttgart.de
Universitaet Stuttgart Tel: ++49-711-68565868
Allmandring 30a Fax: ++49-711-682357
70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
urllib2.urlopen() crashes on Windows 2008 Server Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-03 16:32 +0000
Re: urllib2.urlopen() crashes on Windows 2008 Server Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-12-03 20:07 -0500
Re: urllib2.urlopen() crashes on Windows 2008 Server Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-04 13:00 +0000
Re: urllib2.urlopen() crashes on Windows 2008 Server Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-12-04 13:16 -0500
Re: urllib2.urlopen() crashes on Windows 2008 Server Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-06 09:38 +0000
csiph-web