You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Teja Sai Krishna <sa...@yahoo.com> on 2005/11/03 14:41:18 UTC

invoking IdleConnectionTimeoutThread

Hi 
 
We are calling IdleConnectionTimeoutThread() method to close the idle connections. We have set the setTimeoutInterval as 5000.
 
But this looks like this thread is not invoked after the that particular amount of time. 
 
Do we need to implement Connection Manager and maintain connection pool and get the Connection Manager to close the Idle connections?
 
Can we call IdleConnectionTimeoutThread for each request like this? Which is the best place to invoke this thread? During for each connection?
 
What is the idle time we can use in setTimeoutInterval method to close the idle connections?

My HTTP Client code looks like following
==============================================
public String connect (String reqMsg) throws Exception {
     PostMethod method = new PostMethod(url.toExternalForm());
      HttpClient client = new HttpClient();
      IdleConnectionTimeoutThread ict = new 
      IdleConnectionTimeoutThread();
      ict.addConnectionManager(client.getHttpConnectionManager());
      ict.setConnectionTimeout(5000);
      ict.start();
 try {
                method.setRequestBody(reqMsg);
                int statusCode = client.executeMethod(method);
                results = method.getResponseBodyAsString();
             }
                catch(ConnectException cex){
                 System.out.println("Exception "+cex);
                  }catch(Exception e){
                           System.out.println("Exception occured "+e);
                  }finally{
                      method.releaseConnection();
                    }
                }           
----------------------------------------
 
 Please help me in resolving this issue.
 
Thanks
Teja


Send instant messages to your online friends http://uk.messenger.yahoo.com