commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ludwig, Sven" <SLud...@CONET.DE>
Subject RE: httpclient hangs indefinately
Date Fri, 01 Feb 2002 08:43:53 GMT
Hello,

I read about that issue of blocking IO in the constructors
of java.net.Socket with JDKs up to 1.3 some time ago on javaworld.com
It was easy to find the article again:

http://www.javaworld.com/javaworld/jw-09-1999/jw-09-timeout.html

Along with it there is an implementation "TimedSocket" available: 
(seperate thread that interrupts the connection attempts)

http://www.javaworld.com/jw-09-1999/timeout/jw-09-timeout.zip 

greetings
Sven Ludwig

> -----Original Message-----
> From: JEvans@Cyveillance.com [mailto:JEvans@Cyveillance.com]
> Sent: Thursday, January 31, 2002 7:24 PM
> To: commons-dev@jakarta.apache.org
> Subject: RE: httpclient hangs indefinately
> 
> 
> Well, since the con.open() method creates a new Socket 
> object, it is subject
> to the behavior of the Socket class.  Unfortunately, at least 
> as of 1.3,
> attempting to create a new Socket to a host/port combo that 
> does not answer
> blocks indefinately (or at least for a very long time), this can't be
> avoided directly.  (It would be really nice if the JDK 
> provided a Socket
> constructor that took a timeout value to pass to the 
> underlying OS).  The
> three ways I can think of to avoid it off hand are:
> 
> 	1. Implement a timeout mechanism outside of HttpClient with a
> seperate thread that interrupts the connection attempts.
> 	2. Implement a Socket object in the HttpClient 
> framework that uses
> this same sort of mechanism but hides the details behind the API
> 	3. Use the 1.4 JDK and upgrade everything to use the 
> new channels
> API in non-blocking mode.
> 
> I wish there were a cleaner way.  If anyone knows of one I'd 
> love to hear
> it.
> 
> -
> John
> 
> -----Original Message-----
> From: Allen, Michael B (RSCH) [mailto:Michael_B_Allen@ml.com]
> Sent: Wednesday, January 30, 2002 10:50 PM
> To: 'commons-dev@jakarta.apache.org'
> Subject: httpclient hangs indefinately
> 
> 
> If I just use a simple test program like below and try to 
> connect to certain
> IP addresses that
> are routable but don't have anything listing at the other end (returns
> nothing, dead air), the
> client hangs indefinately. Can anyone think of a solution to 
> this problem?
> 
> Thanks,
> Mike
> 
> import org.apache.commons.httpclient.*;
> 
> public class Test {
> 
>         public static void main(String[] argv) throws Exception {
>                 HttpConnection con = new HttpConnection( argv[0],
> Integer.parseInt( argv[1] ));
>                 con.open();
>                 con.printLine( "GET /index.html HTTP/1.0" );
>                 con.printLine();
>                 String s;
>                 while(( s = con.readLine() ) != null ) {
>                         System.out.println( s );
>                 }
>         }
> }
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:commons-dev-help@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:   
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message