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 547EC17349 for ; Sat, 11 Apr 2015 16:52:40 +0000 (UTC) Received: (qmail 1130 invoked by uid 500); 11 Apr 2015 16:52:40 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 1084 invoked by uid 500); 11 Apr 2015 16:52: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 1073 invoked by uid 99); 11 Apr 2015 16:52:40 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Apr 2015 16:52:40 +0000 Received: from ubuntu.local (254.120.198.178.dynamic.wline.res.cust.swisscom.ch [178.198.120.254]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 63BDD1A0113 for ; Sat, 11 Apr 2015 16:52:39 +0000 (UTC) Message-ID: <1428771156.7896.14.camel@apache.org> Subject: Re: HttpClient write timeout From: Oleg Kalnichevski To: HttpClient User Discussion Date: Sat, 11 Apr 2015 18:52:36 +0200 In-Reply-To: <1428731923651-26011.post@n7.nabble.com> References: <1428731923651-26011.post@n7.nabble.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit On Fri, 2015-04-10 at 22:58 -0700, natl wrote: > As mentioned in > http://mail-archives.apache.org/mod_mbox/hc-httpclient-users/201206.mbox/%3C1339619106.2755.17.camel@ubuntu%3E, > I understand that HttpClient does not have write timeout. However, I ran > into a situation when I upload a large file to a bad written service where > if it cannot read the data with a specific time, it will write the response > back to the client with 408 timeout. However, it will stop reading more data > from the client. This causes Entity.writeTo(OutputStream) to get stuck even > though the response has been received. I wonder whether there is any good > workaround to this one apart from interrupting the thread based on the the > content length. I'd rather prefer the mechanism similar to > socket.setSoTimeout() where the call will fail as soon as a write cannot be > completed within a specific timeframe. > > One thing I notice is that SocketOutputStream.write / SocketInputStream.read > cannot be interrupted. So even though you have another thread waiting for > timeout and then trying to interrupt the thread, you won't be able to do so > with Socket API. > > Thanks, > Try using the async version of HttpClient which can handle out of sequence response messages http://hc.apache.org/httpcomponents-asyncclient-4.0.x/index.html http://hc.apache.org/httpcomponents-asyncclient-4.0.x/examples.html http://hc.apache.org/httpcomponents-asyncclient-4.0.x/httpasyncclient/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org