hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ortwin Gl├╝ck <ortwin.glu...@nose.ch>
Subject Re: java.net.SocketException
Date Wed, 18 Dec 2002 18:45:36 GMT
Adam Jack wrote:
> [java.net.SocketException: Connection reset by peer: JVM_recv in socket
> input stream read] (java.net.SocketException)java.net.SocketException:
> Connection reset by peer: JVM_recv in socket input stream read at


I experienced this a while ago and described this in my posting from 
Friday 18th of October 2002 which I include here:

-----------

I just discovered that there is a problem with Proxy keep-alive 
connections. I tracked this down using a packet sniffer because the 
delay caused by the log output prevented the bug to be reproduced. Let 
me explain what I observed.

A connection is made through a authenticating Squid proxy. The first 
request by the client has no credentials:

GET http://www.nose.ch/ HTTP/1.1
Host: www.nose.ch
User-Agent: Jakarta Commons-HttpClient/2.0M1

So Squid responds with:

HTTP/1.0 407 Proxy Authentication Required
Server: Squid/2.3.STABLE5
Mime-Version: 1.0
Date: Fri, 18 Oct 2002 17:56:40 GMT
Content-Type: text/html
Content-Length: 960
Expires: Fri, 18 Oct 2002 17:56:40 GMT
X-Squid-Error: ERR_CACHE_ACCESS_DENIED 0
Proxy-Authenticate: Basic realm="Squid proxy-caching web server"
X-Cache: MISS from SAM
Proxy-Connection: keep-alive

<HTML>
  [some error page]
</HTML>

Note the Proxy-Connection header!
But the next packet is a TCP FIN, that closes the connection.
The client sends the matching ACK that acknowledges the FIN. So the 
connection is definitely closed.

The HttpClient does not expect a closed connection and tries to resend 
the request.

For some strange reason (MS Windows IP Stack or a Multithreading issue), 
the HttpClient can still write to the socket and sends a:

GET http://www.nose.ch/ HTTP/1.1

This is off course not allowed without any SYN packets (remember the 
connection has been closed) and the proxy answers with a RST packet.

Java the throws a SocketException.


There are two things we learn from this:

1. We should look out for Proxy-Connection headers and not just 
Connection headers.

2. We should gracefully handle unexpectedly closed connections. (Don't 
trust the headers of an angry proxy)

in a hurry

Odi


Mime
View raw message