Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 38DE119101 for ; Fri, 8 Apr 2016 10:04:51 +0000 (UTC) Received: (qmail 68876 invoked by uid 500); 8 Apr 2016 10:04:50 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 68828 invoked by uid 500); 8 Apr 2016 10:04:50 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 68815 invoked by uid 99); 8 Apr 2016 10:04:50 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Apr 2016 10:04:50 +0000 Received: from ok2c (115.85.106.92.dynamic.wline.res.cust.swisscom.ch [92.106.85.115]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 88E3C1A012C; Fri, 8 Apr 2016 10:04:49 +0000 (UTC) Message-ID: <1460109885.17223.2.camel@apache.org> Subject: Re: releasing streamed connections back to connection pool From: Oleg Kalnichevski To: HttpClient User Discussion Cc: Bernd Eckenfels Date: Fri, 08 Apr 2016 12:04:45 +0200 In-Reply-To: References: <57077e04.839a1c0a.67c51.ffffb1af@mx.google.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit On Fri, 2016-04-08 at 11:02 +0100, Tim Webster wrote: > OK...so do you think I need to use this class to explicitly to consume the > response? I can see some methods on there for this. > > Also - I think the call to PostMethod.releaseConnection() will still close > it - do you have any idea if this should / should not be used? > No, it will not. Just make sure your code always consumes response content. Oleg > Thanks, > > > > > On Fri, Apr 8, 2016 at 10:46 AM, Bernd Eckenfels > wrote: > > > It looks like the HttpResponseProxy will be responsible for releasing the > > connection once the entity is consumed. Most likely by wrapping and > > tracking the input stream. > > > > > > > > > > Gruss > > Bernd > > -- > > http://bernd.eckenfels.net > > From Win 10 Mobile > > > > > > > > *Von: *Tim Webster > > *Gesendet: *Freitag, 8. April 2016 11:42 > > *An: *httpclient-users@hc.apache.org > > *Betreff: *releasing streamed connections back to connection pool > > > > > > > > Hi, > > > > > > > > I'm using Spring's HttpComponentsHttpInvokerRequestExecutor in my > > > > application, configured with a PoolingHttpClientConnectionManager. > > > > > > > > It all works fine, except that when a request is executed, the HTTP > > > > connection that was used is closed after every request. This is a result > > > > of Spring calling HttpPost.releaseConnection(). > > > > > > > > Ideally the connections would not be closed, but just released back to the > > > > connection pool. This is especially important for HTTPS connections and > > > > the overhead of handshakes. > > > > > > > > My problem is, when httpPost.releaseConnection() is called, instead of just > > > > releasing the connection back to the pool, it closes it. If you dig into > > > > the code you can see it ends up calling ConnectionHolder.cancel(), where > > > > ideally it would be calling ConnectionHolder.releaseConnection(). > > > > > > > > I thought I could override the Spring code to NOT call > > > > HttpPost.releaseConnection(), figuring the connection manager would take > > > > care of releasing the connection itself, which it does, but not in my case > > > > because it is a streaming request (these are HTTP posts with input stream): > > > > > > > > From MainClientExec.java: > > > > > > > > > > > > // check for entity, release connection if possible > > > > final HttpEntity entity = response.getEntity(); > > > > if (entity == null || !entity.isStreaming()) { > > > > // connection not needed and (assumed to be) in re-usable > > > > state > > > > connHolder.releaseConnection(); > > > > return new HttpResponseProxy(response, null); > > > > } else { > > > > return new HttpResponseProxy(response, connHolder); > > > > } > > > > > > > > So - I don't see a way with the API the way it is to do what I require, > > > > which is release the connection (without closing it) after consuming the > > > > response. > > > > > > > > I'm happy to provide more details/context if anyone can help.... > > > > > > > > thanks, > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org