curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Setting connection timeout per host?

From: Midnight Wonderer via curl-library <>
Date: Mon, 11 Jan 2021 18:43:29 +0700

On Mon, 11 Jan 2021 at 05:24, Daniel Stenberg <> wrote:
> So what would your ideal solution to this in libcurl look like?

As discussed earlier, in my narrow perspective, the only sensible way
to apply connection timeout is to apply per connection attempt. I was
very surprised when I tested by setting the option to 3s but curl give
up after ~1.5s.
Other than that, I think Nginx options should cover most of the other
cases some people care about, especially the option to limit the
number of tries.

Of course, there are other perspectives about it too, but I can't
speak for others.
However, I can think of a way to introduce the new option without much turmoil.
It is to leave the current connection timeout option as is, but define
it with more clarity that it means overall connection timeout and is
shared between multiple connections. Then introduce another option
that defines as a timeout per connection. (Not sure about the name

With only the old option set, curl can keep the old behavior this way;
on the other hand, it should help with the scenario of 20 IP addresses
you mentioned earlier when combined with the new option too.
Received on 2021-01-11