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 A179F190FB for ; Fri, 8 Apr 2016 10:02:40 +0000 (UTC) Received: (qmail 67508 invoked by uid 500); 8 Apr 2016 10:02:40 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 67464 invoked by uid 500); 8 Apr 2016 10:02:40 -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 67452 invoked by uid 99); 8 Apr 2016 10:02:39 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Apr 2016 10:02:39 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 8780BC0A88 for ; Fri, 8 Apr 2016 10:02:39 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id FKj99bCXtIWI for ; Fri, 8 Apr 2016 10:02:35 +0000 (UTC) Received: from mail-vk0-f45.google.com (mail-vk0-f45.google.com [209.85.213.45]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 564A75F39A for ; Fri, 8 Apr 2016 10:02:35 +0000 (UTC) Received: by mail-vk0-f45.google.com with SMTP id k1so132149572vkb.0 for ; Fri, 08 Apr 2016 03:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=cUVmBfcqtnxTgtRN+tVFSiIqChx85Yic1dTuLdaNqsA=; b=YHn1OrnqwB+DmyZYsJPdq549sceft6vN724Y+SV6EAfT5m1b/z4Cr5otQ5oTKHsCTm t7Fpdiy+JhB1H23jiftkC3MMz8H7R4v07xyVzsY0eGrS5p7UF5wVSRuoMMUz3KkDA5MO WcjkDzotTtp5k0RvaCTOL/K6pI2ett3PWetCU8wkryE6pcM0ppUMn9ZIFmuy5wIOyY9/ RYvPEH69lUpooTSSRU9CQFOexMeVxj6xzv/8YWgIB6EDvkM6XWdbqVBFVaL3Bz02RK4l L80T1VTzyWlRvEIxWSwSTnenAWY/FxgVRARn8bYZp7k22BbDPSU3dDT0Y7JsMA4T7Rt1 I14w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cUVmBfcqtnxTgtRN+tVFSiIqChx85Yic1dTuLdaNqsA=; b=mSrpfIfcQPH0nMrAiUIHlVd3+ToLwAiOxzzWa7al3oFGYF+EvkecfOKHrb1+7sWF2h DwS6XOJNz3FOasK+ecIWlklObi4SKv6jRzUS/Oa9bDUFT7weoCMIEqy8rOTSFI5l9Yhc gheG2M/FuiK2OynjEURNZN6Zz7BzSElUacwyyBOvTobNtAXX4TbETxOanHMWCc1bb9GT jpnifTzNuXQAvZJS6nU/SDGvlaS7jB8iKAYdvsUUEOP/fwqNyAdq5RRxezQgR5D/Ua7K /d6a+w0sNqK6wGzmA+lbCeQMwurqrsCJbBJLDO5JpCAgKuSmdyQrlH57hzcSzwtYJDzF PBlg== X-Gm-Message-State: AD7BkJIG0smvFaYZtCv3vIZ3elYY1d62XXq3JZouHSemVmwQkkGtj6WnT3VreP/1+BzO5HyvXCGb+dPCPHAx5Q== X-Received: by 10.31.4.208 with SMTP id 199mr3087247vke.110.1460109748789; Fri, 08 Apr 2016 03:02:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.5.161 with HTTP; Fri, 8 Apr 2016 03:02:09 -0700 (PDT) In-Reply-To: <57077e04.839a1c0a.67c51.ffffb1af@mx.google.com> References: <57077e04.839a1c0a.67c51.ffffb1af@mx.google.com> From: Tim Webster Date: Fri, 8 Apr 2016 11:02:09 +0100 Message-ID: Subject: Re: releasing streamed connections back to connection pool To: Bernd Eckenfels Cc: "httpclient-users@hc.apache.org" Content-Type: multipart/alternative; boundary=001a1142a4d2e8e5be052ff64aeb --001a1142a4d2e8e5be052ff64aeb Content-Type: text/plain; charset=UTF-8 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? 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, > > > --001a1142a4d2e8e5be052ff64aeb--