Hello,

This is a known issue, unfortunately.
I brought it up recently (mailing list archives?) after I saw the same problems as you 
have.

I opted for your 3rd suggestion in my local version of HTTP Client.
It is too early to put that in the distributed version of HTTP Client for now.

As there is no intense development of HTTP Client that's worked fine for me.
I simply used the Socket's connect call with some timeout value.

Otis


On Thu, 31 January 2002, [EMAIL PROTECTED] wrote:

> 
> 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:[EMAIL PROTECTED]]
> Sent: Wednesday, January 30, 2002 10:50 PM
> To: '[EMAIL PROTECTED]'
> 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:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

_________________________________________________________________
iVillage.com: Solutions for Your Life 
Check out the most exciting women's community on the Web   
http://www.ivillage.com

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to