hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cordes, Hans-Dieter" <hdcor...@emea.att.com>
Subject RE: PROBLEM WITH setMaxTotalConnections
Date Fri, 23 Mar 2007 10:58:49 GMT
Hello,

usually there is only one Servlet object instance in a Servlet container, however, I assume
that the code you have showed "lives" in one of the "doGet()/doPost()" etc. Servlet methods.
Keep in mind that the Servlet's code is called in a multithreaded way, so at the same time
there can be several running "doGet()/doPost()" etc methods, and each of them has its own
stack, and on that stack you create different "HttpClient" objects that in turn have there
own "MultiThreadedHttpConnectionManager()" object. You limit the maxConnection to 1, but that
does not have any effect in this context.

What you probably need is a static "HttpClient" object in your Servlet that does your communication.
But keep in mind to "synchronize" access to it! (I have, however, no idea whether this can
really work depending on your needs.)

Regards,
	Hans-Dieter Cordes

-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com] 
Sent: Freitag, 23. März 2007 11:43
To: HttpClient User Discussion
Subject: Re: PROBLEM WITH setMaxTotalConnections

Surely if you make 10 requests to the servlet there will be 10 servlet instances?

It looks like each has its own connection manager ...

On 23/03/07, Joan Balagueró <joan.balaguero@grupoventus.com> wrote:
> Hi,
>
>
>
> I'm trying to limit the total number of http connections in my 
> httpclient instance. I'm using a multithreaded http connection 
> manager. The code is the
> following:
>
>
>
>   HttpClient objHttp = new HttpClient(new 
> MultiThreadedHttpConnectionManager());
>
>   
> objHttp.getHttpConnectionManager().getParams().setMaxTotalConnections(
> 1);
>
>
> objHttp.getHttpConnectionManager().getParams().setConnectionTimeout(co
> nnecti
> onTimeout);
>
>
> objHttp.getHttpConnectionManager().getParams().setSoTimeout(responseTi
> meout)
> ;
>
>
> objHttp.getHttpConnectionManager().getParams().setStaleCheckingEnabled
> (true)
> ;
>
>   objHttp.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
>
>
>
> This is part of a servlet that receives a request and sends an http 
> request to another server using this httpclient. As you can see, I'm 
> limiting the total number to 1 in order to make a test.
>
>
>
> But, if I send to this servlet many simultaneous requests (10 or 
> more), no errors happens and httpclient opens 10 (or more) http 
> connections, ignoring my limit of 1.
>
>
>
> I suppose that I'm misunderstanding something, but I don't know what. 
> Can anybody help me?
>
>
>
> Thanks,
>
>
>
> Joan.
>
>

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


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


Mime
View raw message