[Libwebsockets] Avoiding DNS retries?

Felipe Gasper felipe at felipegasper.com
Fri Jun 25 12:35:10 CEST 2021


> On Jun 25, 2021, at 12:05 AM, andy at warmcat.com wrote:
> 
> 
> 
> On June 25, 2021 3:26:15 AM UTC, Felipe Gasper <felipe at felipegasper.com> wrote:
>> Hello,
>> 
>> 	I’ve noticed that LWS retries DNS lookups by default. Can I disable
>> this, so that the first lookup hard-fails?
> 
> 
> Can you explain your scenario a bit?

> curl http://ajdsdasc.asdsadf
curl: (6) Could not resolve host: ajdsdasc.asdsadf

^^ That ends right away, as I’d expect. Likewise ping, traceroute, et al.

With my demo LWS app, though, it retries several times, even though the DNS lookup receives an error response every time:

-----
[2021/06/25 06:20:12:8592] I: lws_header_table_attach: did attach wsi [wsicli|0|WS/h1/echo.websocket.orggg]: ah 0x7fe43682b030: count 1 (on exit)
[2021/06/25 06:20:12:8592] I: lws_client_connect_2_dnsreq: [wsicli|0|WS/h1/echo.websocket.orggg]: lookup echo.websocket.orggg:80
[2021/06/25 06:20:12:8837] I: lws_getaddrinfo46: getaddrinfo 'echo.websocket.orggg' says 8
[2021/06/25 06:20:12:8837] N: lws_client_connect_3_connect: dns lookup failed 8
other callback (19)
my_perl_context: 0x7fe433c44490
[2021/06/25 06:20:12:8840] I: lws_state_transition_steps: CONTEXT_CREATED -> OPERATIONAL
other callback (71)
[2021/06/25 06:20:13:8871] I: lws_client_dns_retry_timeout: dns retry
[2021/06/25 06:20:13:8871] I: lws_client_connect_2_dnsreq: [wsicli|0|WS/h1/echo.websocket.orggg]: lookup echo.websocket.orggg:80
[2021/06/25 06:20:13:8881] I: lws_getaddrinfo46: getaddrinfo 'echo.websocket.orggg' says 8
[2021/06/25 06:20:13:8882] N: lws_client_connect_3_connect: dns lookup failed 8
[2021/06/25 06:20:14:8915] I: lws_client_dns_retry_timeout: dns retry
[2021/06/25 06:20:14:8915] I: lws_client_connect_2_dnsreq: [wsicli|0|WS/h1/echo.websocket.orggg]: lookup echo.websocket.orggg:80
[2021/06/25 06:20:14:8933] I: lws_getaddrinfo46: getaddrinfo 'echo.websocket.orggg' says 8
[2021/06/25 06:20:14:8933] N: lws_client_connect_3_connect: dns lookup failed 8
[2021/06/25 06:20:15:8976] I: lws_client_dns_retry_timeout: dns retry
[2021/06/25 06:20:15:8976] I: lws_client_connect_2_dnsreq: [wsicli|0|WS/h1/echo.websocket.orggg]: lookup echo.websocket.orggg:80
[2021/06/25 06:20:15:8992] I: lws_getaddrinfo46: getaddrinfo 'echo.websocket.orggg' says 8
[2021/06/25 06:20:15:8992] N: lws_client_connect_3_connect: dns lookup failed 8
[2021/06/25 06:20:16:9040] I: lws_client_dns_retry_timeout: dns retry
[2021/06/25 06:20:16:9041] I: lws_client_connect_2_dnsreq: [wsicli|0|WS/h1/echo.websocket.orggg]: lookup echo.websocket.orggg:80
[2021/06/25 06:20:16:9055] I: lws_getaddrinfo46: getaddrinfo 'echo.websocket.orggg' says 8
[2021/06/25 06:20:16:9055] N: lws_client_connect_3_connect: dns lookup failed 8
[2021/06/25 06:20:17:9094] I: lws_client_dns_retry_timeout: dns retry
[2021/06/25 06:20:17:9094] I: lws_client_connect_2_dnsreq: [wsicli|0|WS/h1/echo.websocket.orggg]: lookup echo.websocket.orggg:80
[2021/06/25 06:20:17:9109] I: lws_getaddrinfo46: getaddrinfo 'echo.websocket.orggg' says 8
[2021/06/25 06:20:17:9109] N: lws_client_connect_3_connect: dns lookup failed 8
[2021/06/25 06:20:18:9147] I: lws_client_dns_retry_timeout: dns retry
[2021/06/25 06:20:18:9148] I: lws_client_connect_2_dnsreq: [wsicli|0|WS/h1/echo.websocket.orggg]: lookup echo.websocket.orggg:80
[2021/06/25 06:20:18:9162] I: lws_getaddrinfo46: getaddrinfo 'echo.websocket.orggg' says 8
[2021/06/25 06:20:18:9163] N: lws_client_connect_3_connect: dns lookup failed 8
[2021/06/25 06:20:19:9196] I: lws_client_dns_retry_timeout: dns retry
[2021/06/25 06:20:19:9196] I: lws_client_connect_2_dnsreq: [wsicli|0|WS/h1/echo.websocket.orggg]: lookup echo.websocket.orggg:80
[2021/06/25 06:20:19:9209] I: lws_getaddrinfo46: getaddrinfo 'echo.websocket.orggg' says 8
[2021/06/25 06:20:19:9209] N: lws_client_connect_3_connect: dns lookup failed 8
[2021/06/25 06:20:20:9257] I: lws_client_dns_retry_timeout: dns retry
[2021/06/25 06:20:20:9257] I: lws_client_connect_2_dnsreq: [wsicli|0|WS/h1/echo.websocket.orggg]: lookup echo.websocket.orggg:80
[2021/06/25 06:20:20:9272] I: lws_getaddrinfo46: getaddrinfo 'echo.websocket.orggg' says 8
[2021/06/25 06:20:20:9272] N: lws_client_connect_3_connect: dns lookup failed 8
[2021/06/25 06:20:21:9284] I: lws_client_dns_retry_timeout: dns retry
[2021/06/25 06:20:21:9285] I: lws_client_connect_2_dnsreq: [wsicli|0|WS/h1/echo.websocket.orggg]: lookup echo.websocket.orggg:80
[2021/06/25 06:20:21:9300] I: lws_getaddrinfo46: getaddrinfo 'echo.websocket.orggg' says 8
[2021/06/25 06:20:21:9301] N: lws_client_connect_3_connect: dns lookup failed 8
[2021/06/25 06:20:22:8592] I: lws_sul_wsitimeout_cb: [wsicli|0|WS/h1/echo.websocket.orggg]: TIMEDOUT WAITING on 25 (did hdr 0, ah 0x7fe43682b030, wl 0)
[2021/06/25 06:20:22:8592] I: __lws_close_free_wsi: [wsicli|0|WS/h1/echo.websocket.orggg]: caller: timeout
-----

Retries make sense if the request times out, but if it receives a DNS response, wouldn’t it make more sense to fail right away?

In fact, that seems to be what LWS does if I build with LWS_WITH_SYS_ASYNC_DNS=1; there’s no “DNS lookup failed” message that I see, but the connection attempt ends right away, whereas if I put in a valid name to connect to things work as I’d expect.

Is it intended that async DNS fail right away while getaddrinfo() retries even on known failure states?

-F


More information about the Libwebsockets mailing list