hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sinead Whelan <sinead.e.whe...@aib.ie>
Subject Pooling HttpClient
Date Tue, 11 Feb 2003 20:44:14 GMT
Hi

I wish to use HttpClient in a servlet based application. The HttpClient will be used to communicate
with another internal server (always the same server). This communications will be in HTTP
over SSL and I would like to be able to reuse connections to the server without having to
do an expensive SSL handshake all the time. I would intend to have a long timeout on the HTTP
connection (~15 minutes).

Currently in my servlet I have code similar to below,

class MyServlet extends HttpServlet {

   static HttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
   static HttpClient httpClient = new HttpClient(httpConnectionManager);

    public void init() {
        httpConnectionManager.setMaxConnectionsPerHost(150);
    }


    public void doPost(Req req, Response resp) {
        PostMethod post = new PostMethod(url.getPath());
        post.setRequestContentLength(PostMethod.CONTENT_LENGTH_CHUNKED);
       post.addParameter("TestReq", "Hello");
    
        int result = httpClient.executeMethod(post);

        post.releaseConnection();
    }
    
}

This does not appear to work when a few users/threads are accessing the servlet at the same
time. I get the following error message on the executeMethod():

Recoverable exception caught when reading response - couldn't find valid http header. (or
something like that!)

Do you think that this is the correct way to use it if you want to pool connection to same
server (should I use static HttpClient)?

Any help would be greatly appreciated.

Cheers

Sinead


**********************************************************************
This document is strictly confidential and is intended for use by
 the addressee unless otherwise indicated.

Allied Irish Banks
**********************************************************************


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message