hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ray Hooker <rhoo...@cisco.com>
Subject HttpClient 4.0.1 and Timeout
Date Mon, 24 May 2010 19:21:09 GMT

I am having trouble getting my client to timeout with a non-responsive host. 
I should say up front that I am doing authentication discovery to setup
valid auth credentials for hosts that I am managing.  

The other big deal is that I am using https and the hosts have self-signed
certificates.  The reason I mention this it that I had to use a sample for
custom protocol handler.  This has been deprecated but works nicely:

Protocol myhttps = new Protocol("https", (SecureProtocolSocketFactory) new
EasySSLProtocolSocketFactory(), 443);

Here is my code:
***********************Begin Code Snippet********* (I am importing
apache.commons.httpclient version 3.1) HttpClient CTMclient = new
HttpClient(); Protocol myhttps = new Protocol("https",
(SecureProtocolSocketFactory) new EasySSLProtocolSocketFactory(), 443);
Protocol.registerProtocol("https", myhttps);
CTMclient.getParams().setAuthenticationPreemptive(true);
CTMclient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, 443,
AuthScope.ANY_REALM), defaultcreds); CTMclient.setConnectionTimeout(15000); 
****  Note I am setting the timeout.
GetMethod methodget = new
GetMethod("https://"+CTMurl+"/cgi-bin?tbAction=TB_CONFIG_CALL_STATISTICS");

try {
	statusCode = CTMclient.executeMethod(methodget);
	.....................
**********************End Code Snippet **************

This works beautifully so long as the host is responsive.  I am able to
handle the unsigned certificate transparently and successfully authenticate. 
The only problem is that with non-responsive hosts, it never times out.  I
saw some code snippets setting the timeout using httpparms, but I then have
to switch to BasicHttpClient and away from httpcommons libraries.  I was not
able to get the authentication to work.

Does anyone have a way to set the timeout other than the above?.. or a
pointer to working code examples that include authentication and the use of
custom protocol for the self-signed cert?

Ray



-- 
View this message in context: http://old.nabble.com/HttpClient-4.0.1-and-Timeout-tp28660766p28660766.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message