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: Question about DNS timeout in libCurl

From: Dmitry Karpov via curl-library <curl-library_at_lists.haxx.se>
Date: Fri, 10 Dec 2021 23:18:13 +0000

> I agree that 5 seconds is a very long time that should probably be lowered, but that timeout logic in curl is also only used when an old c-ares version is used so maybe the effort is better spent elsewhere anyway?

Could you please clarify the last point about the old c-ares version? I stepped on this issue using c-ares 1.17.1, which I think it is not that old.

> I don't think it will be particularly risky, no. I also think we should be able to lower the default timeout somewhat. I do however think that this is mostly a problem for c-ares itself to handle. I mean, we don't set any timeout values at all when we use libc's resolver functions...

I agree with you that it is mostly a c-ares problem but lowering the default timeout in c-ares itself may create sudden issues in the apps that rely on this value.
The current libcurl version hard codes this value and relies on this as a c-ares documented feature, so I doubt that the default c-ares timeout will change in the future to avoid issues with existing apps.

So, the most logical way to decrease the default DNS timeout used in libcurl seems to implement some logic controlling timing of DNS queries.
In case of c-ares used as a DNS resolver, such logic may use c-ares API for setting the timeout, for other resolvers it may use something else or just rely on the defaults.

DNS query is important part of connection establishment, so it seems quite logical to provide an option to control it if it is possible.

Thanks,
Dmitry Karpov


-----Original Message-----
From: Daniel Stenberg <daniel_at_haxx.se>
Sent: Friday, December 10, 2021 2:35 PM
To: Dmitry Karpov via curl-library <curl-library_at_lists.haxx.se>
Cc: Dmitry Karpov <dkarpov_at_roku.com>
Subject: Re: Question about DNS timeout in libCurl

On Fri, 10 Dec 2021, Dmitry Karpov via curl-library wrote:

> While parallel query requests in c-ares are not there yet, I am
> wondering if it is possible to control DNS timeout or expose such
> control via curl handle options in the future? I noticed that libcurl
> always uses the default c-ares timeout value, which is 5s, and happy
> eyeball DNS timeout also relies on that value by hard coding it in the
> HAPPY_EYEBALLS_DNS_TIMEOUT constant, but in some cases, 5s may be a
> too long wait before switching to a different name server.

I agree that 5 seconds is a very long time that should probably be lowered, but that timeout logic in curl is also only used when an old c-ares version is used so maybe the effort is better spent elsewhere anyway?

> I am wondering, if you think that doing such changes will be a very
> risky change even as a short-term solution?

I don't think it will be particularly risky, no. I also think we should be able to lower the default timeout somewhat. I do however think that this is mostly a problem for c-ares itself to handle. I mean, we don't set any timeout values at all when we use libc's resolver functions...

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html
-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2021-12-11