commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allen, Michael B (RSCH)" <Michael_B_Al...@ml.com>
Subject RE: httpclient hangs indefinately
Date Sun, 03 Feb 2002 22:05:58 GMT

> -----Original Message-----
> From:	JEvans@Cyveillance.com [SMTP:JEvans@Cyveillance.com]
> 
> 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: JEvans@cyveillance.com [mailto:JEvans@cyveillance.com]
> 
> 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).
> 
	Actually I must confess, I'm sort of trolling. I'm the author of jCIFS
	(the SMB client) and I wanted to know how you addressed this problem. I did
	not know eventually a Connection timed out exception is thrown. This is good
	news. I have done a bit of research elsewhere and found out 1.4 does indeed
	have a timeout parameter for the Socket constructor. Unfortunately that doesn't
	help me because jCIFS still supports 1.1 and it would be a shame to break that.

>   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.
> 
	Tried and failed. If you look up my (mballen@erols.com) recent post to
	comp.lang.java.programmer you'll see I tested this by trying to interrupt() the
	Socket() calling Thread. The results depend on which jre you're using but both
	end up sticking in Socket() in an interrupted state.

> 	2. Implement a Socket object in the HttpClient framework that uses
> this same sort of mechanism but hides the details behind the API
> 
	With JNI?

> 	3. Use the 1.4 JDK and upgrade everything to use the new channels
> API in non-blocking mode.
> 
	JDK 1.4 has a timeout parameter for Socket().

	Thanks,
	Mike
	http://jcifs.samba.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