Incidentally, it doesn't actually hang indefinately, for me it looks like it times out after about 3 minutes and 12 seconds.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 31, 2002 1:24 PM To: [EMAIL PROTECTED] 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:[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]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
