On Mar 12, 2010, at 6:28am, <[email protected]> <[email protected] > wrote:

Hi all,
I using DefaultHttpClient to talk to a web server. That server has lately become so loaded that my connection times out. How do I increase it? I can't find a method in DefaultHttpClient to set the timeout.

When you create the DefaultHttpClient, you can specify an HttpParams parameter that contains configuration information, including various timeout values.

See 
http://hc.apache.org/httpcomponents-client/tutorial/html/connmgmt.html#d4e391

And also 
http://hc.apache.org/httpcomponents-core/httpcore/apidocs/org/apache/http/params/HttpConnectionParams.html

A typical snippet looks like:

            HttpParams params = new BasicHttpParams();
            ....
            HttpConnectionParams.setSoTimeout(params, _socketTimeout);
HttpConnectionParams.setConnectionTimeout(params, _connectionTimeout);
            ....
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
            _httpClient = new DefaultHttpClient(cm, params);

-- Ken

--------------------------------------------
Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c   w e b   m i n i n g


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to