Saturday, May 7, 2011

Setting Connection timeout using HTTPClient

To provide timeout for HttpClient create a HttpParams Object and set Http timeout and socket timeouts .

Code Snippet
   
HttpParams httpParameters  = new BasicHttpParams();
// Set the timeout in milliseconds 
HttpConnectionParams.setConnectionTimeout(httpParameters, 30000);

HttpConnectionParams.setSoTimeout(httpParameters,30000);

DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);

No comments:

Post a Comment