Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9989C18AE4 for ; Mon, 11 Jan 2016 03:51:22 +0000 (UTC) Received: (qmail 14565 invoked by uid 500); 11 Jan 2016 03:51:22 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 14520 invoked by uid 500); 11 Jan 2016 03:51:22 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 14508 invoked by uid 99); 11 Jan 2016 03:51:22 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jan 2016 03:51:22 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id B4348C2E8C for ; Mon, 11 Jan 2016 03:51:21 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.102 X-Spam-Level: X-Spam-Status: No, score=-0.102 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 5MTy8Mf0XIiJ for ; Mon, 11 Jan 2016 03:51:20 +0000 (UTC) Received: from mail-qg0-f53.google.com (mail-qg0-f53.google.com [209.85.192.53]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id E2DDF43C53 for ; Mon, 11 Jan 2016 03:51:14 +0000 (UTC) Received: by mail-qg0-f53.google.com with SMTP id o11so394716060qge.2 for ; Sun, 10 Jan 2016 19:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=2TYFGl3WiETJVk1+vh9EC+WMDEidSK29bplbwo8/MR0=; b=F3GSBw5mg3eM9EC4xD06YABE6/BSsKgsviupuA2wzrNwwocVFct5c4H0VXgRMfRswT xQ9YNFYkc6MarggHVr3JoYd9glLMJ5pVoTopmgfBEWfssifjHvIE4nTQ5/z+jDm3tjv4 phKd0SiJTzkTz5ZHCCDec543t4DMZUJNEuUqmbNlBt4tGT0F8kDMCmeKbvd4GrInzVzk PUMlNTrwsp+bTT5jIcz53dwAjvwSNIQPCKdNKfwUDRbDsAw3cf108O95kUe1jzQH1rys rp7bmZxoausbV8bdJO28191pG0jCcAT+3OWgAHDqkeILEklYHyHs0da11End83Xcfwna 9Wjw== X-Received: by 10.140.160.193 with SMTP id g184mr160515598qhg.86.1452484274528; Sun, 10 Jan 2016 19:51:14 -0800 (PST) Received: from [192.168.0.104] (modemcable019.25-21-96.mc.videotron.ca. [96.21.25.19]) by smtp.gmail.com with ESMTPSA id v78sm28351075qge.25.2016.01.10.19.51.13 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 Jan 2016 19:51:13 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Subject: Re: Default timeouts From: Gaspard Petit In-Reply-To: <1452086834.15625.3.camel@apache.org> Date: Sun, 10 Jan 2016 22:51:18 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: <1B94B260-077D-42FF-BF54-2445E9F44F93@gmail.com> References: <2356A8A3-B4FA-4DD4-A190-662DAB0DCDC6@gmail.com> <1452086834.15625.3.camel@apache.org> To: HttpComponents Project X-Mailer: Apple Mail (2.3112) Hi Oleg, Thank you for taking the time to respond my comment. I agree with you that timeouts are not one-size-fits-all. However, I = cannot think of any real-world application that would require to use an = infinite timeout. When the SSL handshake has been waiting on the socket = for over 2 days, there is no doubt that the application is in failure = state and should either retry or abandon. The cases where infinite timeouts are useful, in my opinion, are = strictly when debugging the code, to let you grab a coffee while = stepping through the code. Anything between 20s and 2 minutes would be reasonable. I would = personally go for something like this: Default SSL Handshake socket timeout : 30s Socket (Request) timeout : 30s Connection timeout : 60s Most likely, current HttpClient users are already defining their = timeouts, so only few users should be negatively impacted by such a = change. On the other end, any new user will immediately benefit from = more practical default values. In the end, my biggest concern is the ssh socket timeout, since it is = the most tricky to configure and a lot of sample code I found on the = internet did not mention this timeout. If you are hesitating, I would = at least set a finite default for that one. Gaspard > On Jan 6, 2016, at 8:27 AM, Oleg Kalnichevski = wrote: >=20 > On Tue, 2016-01-05 at 21:52 -0500, Gaspard Petit wrote: >> Hello, >>=20 >> This is a follow up of the comment I posted on = https://issues.apache.org/jira/browse/HTTPCLIENT-1478 >>=20 >> My understanding is that there are 4 timeouts used in the = HttpClient=E2=80=99s API : >>=20 >> a per request socket timeout, configured using = RequestConfig.Builder.setSocketTimeout which affects the io operations = of the socket used to transfer data over http; >> a per request connection timeout, configured using = RequestConfig.Builder.setConnectTimeout, which affects the establishment = of the connection with the web server; >> a per request pool timeout, configured using = RequestConfig.Builder.setConnectionRequestTimeout, which affects the = maximum time to wait for a client to be available in the client pool. = This one defaults to the value set with = RequestConfig.Builder.setConnectTimeout. >> a per connection socket timeout, used for ssl tunnelling, configured = using SocketConfig.custom().setSoTimeout, which affects the timeout for = establishing the ssl tunnel connection. >>=20 >> My understanding is that all these timeouts have default value of = no-timeout. >>=20 >> There are numerous threads on the internet about people falling into = the trap of not setting a default timeout only to discover, days later, = that their app is stuck - a simple google search for "httpclient = stuck=E2=80=9D will convince you. >>=20 >> Among these posts, some people have been setting timeout values for = connection, but find out the hard way that SSL connections have their = own timeout setting. >>=20 >> I am writing to suggest that the default timeout values be changed = for something long but not infinite. The current infinite value make = the API more complex to use since HTTPClients.createDefault() - which = should provide a client with recommended settings, returns instead a = client that is dangerous to use (i.e. it may hang infinitely). >>=20 >> It seems to me that all the above timeout, except the = connectionRequestTimeout, should have finite timeout by default. >>=20 >> While we are in the topic of defaults, I would like to bring up the = default values for the PoolingHttpClientConnectionManager. Even the = tutorial for HttpComponents mentions that the default limits are low: = "Per default this implementation will create no more than 2 concurrent = connections per given route and no more 20 connections in total. For = many real-world applications these limits may prove too constraining, = especially if they use HTTP as a transport protocol for their = services.=E2=80=9D = (https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.htm= l). >>=20 >> This is also discussed in numerous posts on the internet. Why not = make HttpClient ready for "real-world applications=E2=80=9D by default = and use 200 max connections, 20 max per route? >>=20 >=20 > Hi Gaspard >=20 > This limit has already been relaxed in 5.0 (trunk). The trouble with > timeouts is that their values tend to be highly application specific. = I > am not sure what defaults could be considered 'real-world applicable'.=20= >=20 > Oleg >=20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org > For additional commands, e-mail: dev-help@hc.apache.org >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org