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: How Handle DNS timeout cases from Application

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 8 Jun 2020 10:20:46 +0200 (CEST)

On Mon, 8 Jun 2020, Jayashankara DM via curl-library wrote:

> When DNS resolution is not possible for some reason (like DNS server is down
> or can be any other reason) our application is crashing.

That sounds like an application error. Why does it crash because of this? A
failed resolve should make libcurl simply return an error and that should not
make your application crash.

I think you should dig into this crash and figure out more about why this
happens.

> Can please let me know how to handle this case in our application

Check the return code?

> We tried setting CURLOPT_NOSIGNAL = 1 which solves this problem, But leads
> to some other issues like not handling dynamic server down issues.

If setting this option this solves the problem, something was wrong to begin
with. CURLOPT_NOSIGNAL is not a very good band aid for crashes.

> Can you please suggest how to handle the DNS resolution issues ( May be
> timeout or DNS server is wrong or DNS server is not configured ) from
> application point of view to avoid the crash ?

You can set a timeout with CURLOPT_CONNECTTIMEOUT. But again, your application
should never crash because of a timeout, with or without using this option.

> Please also let me know "curl-7.63.0" is by default support "threaded
> resolver" or from which curl version onward "threaded resolver " is
> supported by default ?

It does yes, but you can also see that at the end of the configure run and
with curl -V and curl_version_info() if you're not sure. (They shold show
asynchdns as a feature while *not* mentioning c-ares being used.)

> One basic question: We have a board with curl 7.49.1 and Client application
> is built with curl-7.63.0 (libcurl.so dynamic library) .

You can only use one libcurl version, so you *either* use 7.49.1 or 7.63.0.

I would recommend the latter.

-- 
  / daniel.haxx.se | Commercial curl support up to 24x7 is available!
                   | Private help, bug fixes, support, ports, new features
                   | https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2020-06-08