hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Becke <be...@u.washington.edu>
Subject Re: Timeout in HTTP
Date Mon, 09 Jun 2003 03:41:42 GMT
> Socket connect timeout is dependent on the OS.
> It is configurable since jdk1.4 through code by creating an unbound 
> socket and using connect(SocketAddress, timeout)
> If one uses java.net.URLConnection there are also:
> 	sun.net.client.defaultConnectTimeout (default: -1)
> 	sun.net.client.defaultReadTimeout (default: -1)
> See http://java.sun.com/j2se/1.4.1/docs/guide/net/properties.html

Quite so.  I forgot this was added in 1.4.  Adding support for native 
connect timeout in HttpClient will require an interface change I think, 
so it will have to wait until at least 2.1.  As always other thoughts 
are welcome.

> Has anyone actually tried to contact a server that is down and 
> received a timeout?
> In my experience, trying to interrupt a socket while it is trying to 
> connect (as in the TimeoutController) does nothing until the actual OS 
> timeout kicks in.

I have and it seems to work.  After a little investigation I agree with 
you.  It seems that interrupting a thread blocked in Socket() does 
nothing.  In our case though this is not really a problem since the 
socket is opened from a new thread.  Once the timeout occurs the 
original thread interrupts the connect thread (which appears to do 
nothing) and then throws an exception.  The timeout still occurs though 
it doesn't keep the socket from being opened.  The only problem here is 
the possibility of an orphaned thread blocked in Socket().

Mike


Mime
View raw message