commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis.gospodne...@blink.com>
Subject HTTP Client: HttpConnection patch
Date Sun, 13 Jan 2002 21:10:33 GMT
Hello,

A few times I mentioned that HttpConnection hangs when it encounters 
servers that are down, unreachable, etc.
I did a bit of debugging and it appears that it is calls to 'new 
Socket(....)' that are blocking.  Furthermore, it looks like there is no 
simple cure for that in Java's version 1.3 of the API.

However, JDK 1.4 exposes a 'connect' method in Socket class, which 
allows a timeout value to be specified.

I modified my local version of HttpClient to use that and it works 
perfectly.  I was doing tests with a set of about 1150 URLs and 10 
threads.  Before this change it would take about 16 minutes to fetch 
1150 pages, and now it takes about 3. Note that I hard-coded the connect 
timeout value, but I realize that the default value should probably be 
in a static final int and that we should probably expose this via a 
public method that allows one to set the timeout value.

I understand that not everyone will want to use it, but it may be good 
to apply this patch anyway and then comment it out, so that it is easy 
for people to uncomment it out and use it.  Or perhaps HttpConnection 
could check one of the System properties that shows the JVM version and
use either the old or the new code, depending on the property.

What do you think?

Otis

Mime
View raw message