Hello Oleg, Thanks for your response.
What I mean by removing keep alive strategy is the following. I have an administration application with the following option: [x] Keep alive http connection for [ xxxx ] seconds. If the user checks this option, he must enter a number greather than 0 as keep alive duration. Then I set my own KeepAliveStrategy with: this.objHttp.setKeepAliveStrategy(new VPFWConnectionKeepAliveStrategy(keepAliveDuration)); But now imagine that the same user unchecks this option. Then, I should apply the default keep alive strategy. And what is this? Keep alive indefinitely? Pass to 'VPFWConnectionKeepAliveStrategy' an Integer.MAX_VALUE value? Thanks, Joan. -----Mensaje original----- De: Oleg Kalnichevski [mailto:ol...@apache.org] Enviado el: viernes, 18 de junio de 2010 12:25 Para: HttpClient User Discussion Asunto: Re: Keep alive questions On Wed, 2010-06-16 at 17:55 +0200, Joan Balaguero wrote: > Hello, > > > > I have three questions abut keeupAlive: > > > > > > 1. If “getKeepAliveDuration” returns 0, that means: > > a. No keep alive > OR > b. Keep connections alive indefinitely. > > Neither. It means the connection will be placed in the pool and will expire immediately. > > 2. If I want to remove the keep alive strategy, what should I do? Call > “http.setKeepAliveStrategy(null)”? > What do you mean by removing keep alive strategy? Not re-using connections at all? Anyways, you should implement a custom ConnectionKeepAliveStrategy if you want to customize the keep-alive time of persistent connections. If you so not want connections to be kept-alive at all (which is generally not recommended) you should implement a custom ConnectionReuseStrategy. > > > 3. At this moment, I have an IdleConnectionHandler that is triggered > every 30 seconds and does the following: > > > > this.cm.closeExpiredConnections(); > > this.cm.closeIdleConnections(this.idleTimeout, TimeUnit.SECONDS); > > > > But if I set a keep alive strategy, then it’s not necessary to call to > “closeExpiredConnections”, is it? > It is not necessary but recommended. Without #closeExpiredConnections an expired connection will remain in the pool until a request for a connection lease is made. You may really want to evict expired connections from the pool on a more regular basis. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.829 / Virus Database: 271.1.1/2944 - Release Date: 06/18/10 08:35:00 --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org