algesten / ureq

A simple, safe HTTP client
Apache License 2.0
1.62k stars 168 forks source link

Timeouts for DNS lookups #79

Open jsha opened 4 years ago

jsha commented 4 years ago

Right now ureq has no way to time out DNS lookups. It uses to_socket_addrs, which says:

Note that this function may block the current thread while resolution is performed.

Under the hood, I believe this uses getaddrinfo on Linux, which does not allow setting a timeout.

Some documentation about how curl handles this is here: https://github.com/curl/curl/blob/26d2755d7c3181e90e46014778941bff53d2309f/lib/hostip.c#L91-L115. It sounds like the options are:

This may not be a terribly big priority because in practice getaddrinfo does have built-in timeouts on many systems. For instance, on Linux the default config has a timeout of 5s for name resolution. The Windows default is 15s.

algesten commented 7 months ago

Related to #618