[Libwebsockets] 回复: 答复: A question about libwebsockets dns resolve
Andy Green
andy at warmcat.com
Tue May 19 07:51:51 CEST 2020
On 5/19/20 4:09 AM, huangkaicheng wrote:
> Hi,
> Now libwebsockets can work well in linux and windows. But in OSX(mac ), it still not take effect. And I also set default timeout (secs): 5. It didn’t not not try next.
What exactly did you try? I just did this with current master on a mac
mini, at the default 30s connect timeout
% ./bin/lws-minimal-http-client --server blackhole.bogus.warmcat.com -d
1039 -m
...
[2020/05/19 06:38:56:1963] I: lws_client_connect_2_dnsreq: adding active
conn 0x7fe187f09120
[2020/05/19 06:38:56:1963] I: lws_client_connect_2_dnsreq:
0x7fe187f09120: lookup blackhole.bogus.warmcat.com:443
[2020/05/19 06:38:56:1963] I: lws_retry_sul_schedule: sul
0x7fe187f098f0: scheduling retry in 566ms
[2020/05/19 06:38:56:1963] I: lws_state_transition_steps:
CONTEXT_CREATED -> OPERATIONAL
[2020/05/19 06:38:56:7707] I: lws_retry_sul_schedule: sul
0x7fe187f098f0: scheduling retry in 1178ms
[2020/05/19 06:38:56:7708] I: lws_issue_raw: ssl_capable_write (45) says 45
[2020/05/19 06:38:56:7714] I: lws_buflist_aware_read: wsi
0x7fe187c24300: rops_handle_POLLIN_raw_skt: ssl_capable_read 45
[2020/05/19 06:38:56:7714] I: lws_adns_parse_udp: create cache entry for
blackhole.bogus.warmcat.com, 28
[2020/05/19 06:38:57:9547] I: lws_retry_sul_schedule: sul
0x7fe187f098f0: scheduling retry in 1342ms
[2020/05/19 06:38:57:9547] I: lws_issue_raw: ssl_capable_write (45) says 45
[2020/05/19 06:38:57:9553] I: lws_buflist_aware_read: wsi
0x7fe187c24300: rops_handle_POLLIN_raw_skt: ssl_capable_read 77
[2020/05/19 06:38:57:9553] I: lws_adns_parse_udp: create cache entry for
blackhole.bogus.warmcat.com, 156
[2020/05/19 06:38:57:9554] I: lws_async_dns_store: 0:
blackhole.bogus.warmcat.com: 5.5.5.5
[2020/05/19 06:38:57:9554] I: lws_async_dns_store: 1:
blackhole.bogus.warmcat.com: 46.105.127.147
[2020/05/19 06:38:57:9554] I: lws_client_connect_3_connect:
blackhole.bogus.warmcat.com ipv4 5.5.5.5
[2020/05/19 06:39:27:9647] I: lws_client_conn_wait_timeout: connect wait
timeout has fired
[2020/05/19 06:39:27:9647] I: lws_client_connect_3_connect: abandoning
connect due to timeout
[2020/05/19 06:39:27:9648] I: lws_client_connect_3_connect: (null) ipv4
46.105.127.147
[2020/05/19 06:39:27:9811] I: lws_client_connect_3_connect: getsockopt
check: conn OK
[2020/05/19 06:39:27:9811] I: lws_client_connect_3_connect: Connection
started 0x7fe187f09a70
[2020/05/19 06:39:27:9811] I: lws_client_connect_4_established: wsi
0x7fe187f09120: h1 http client created own conn (raw 0) vh defaultm st 0x202
...
I noticed it had LWS_WITH_SYS_ASYNC_DNS=1, I rebuilt with =0 but it
seems rotating the dns result locally in the libc is a Linux-only thing,
its first result from the blackhole list rotated when it fetched it was
the valid one and it just connects every time since the libc leaves it
alone.
I tried instead onevalid.bogus.warmcat.com, it's not quite the same but
it also worked:
[2020/05/19 06:45:04:1386] I: lws_client_connect_2_dnsreq:
0x7f9c3adde9a0: lookup onevalid.bogus.warmcat.com:443
[2020/05/19 06:45:04:2116] I: lws_getaddrinfo46: getaddrinfo
'onevalid.bogus.warmcat.com' says 0
[2020/05/19 06:45:04:2116] I: lws_client_connect_3_connect:
onevalid.bogus.warmcat.com ipv4 127.0.0.3
[2020/05/19 06:45:04:2119] I: lws_state_transition_steps:
CONTEXT_CREATED -> OPERATIONAL
[2020/05/19 06:45:34:2185] I: lws_client_conn_wait_timeout: connect wait
timeout has fired
[2020/05/19 06:45:34:2185] I: lws_client_connect_3_connect: abandoning
connect due to timeout
[2020/05/19 06:45:34:2185] I: lws_client_connect_3_connect: (null) ipv4
127.0.0.1
[2020/05/19 06:46:04:2186] I: lws_client_conn_wait_timeout: connect wait
timeout has fired
[2020/05/19 06:46:04:2186] I: lws_client_connect_3_connect: abandoning
connect due to timeout
[2020/05/19 06:46:04:2186] I: lws_client_connect_3_connect: (null) ipv4
127.0.0.2
[2020/05/19 06:46:34:2279] I: lws_client_conn_wait_timeout: connect wait
timeout has fired
[2020/05/19 06:46:34:2279] I: lws_client_connect_3_connect: abandoning
connect due to timeout
[2020/05/19 06:46:34:2280] I: lws_client_connect_3_connect: (null) ipv4
46.105.127.147
[2020/05/19 06:46:34:2444] I: lws_client_connect_3_connect: getsockopt
check: conn OK
[2020/05/19 06:46:34:2444] I: lws_client_connect_3_connect: Connection
started 0x7f9c3ac31d90
[2020/05/19 06:46:34:2444] I: lws_client_connect_4_established: wsi
0x7f9c3adde9a0: h1 http client created own conn (raw 0) vh defaultm st 0x202
...
-Andy
> Huangkaicheng
>
> -----邮件原件-----
> 发件人: Andy Green [mailto:andy at warmcat.com]
> 发送时间: 2020年5月11日 21:17
> 收件人: huangkaicheng <huangkaicheng at huawei.com>; libwebsockets <libwebsockets at ml.libwebsockets.org>
> 抄送: Chenyake <chenyake at huawei.com>
> 主题: Re: 答复: 回复: 回复: [Libwebsockets] 答复: A question about libwebsockets dns resolve
>
>
>
> On 5/11/20 12:42 PM, huangkaicheng wrote:
>> Hi,
>> I have update the latest code of master, it seem that it does not takes effect. I set default timeout (secs): 5.
>
> The patch is fine... the problem is windows doesn't follow the POSIX rule that it should set POLLOUT on the connection when the connect() has completed.
>
> I pushed another patch on master aimed at that. But it seems windows libc doesn't rotate the DNS results each time like linux does, it's harder to test it because the ordering of the results seems fixed until it fetches it again from the DNS server.
>
> -Andy
>
More information about the Libwebsockets
mailing list