[Libwebsockets] 答复: 回复: 回复: 答复: A question about libwebsockets dns resolve

huangkaicheng huangkaicheng at huawei.com
Mon May 11 13:42:34 CEST 2020

    I have update the latest code of master, it seem that it does not takes effect. I set default timeout (secs): 5. 

发件人: Andy Green [mailto:andy at warmcat.com] 
发送时间: 2020年5月11日 16:53
收件人: o_O凌雲 <550470999 at qq.com>; libwebsockets <libwebsockets at ml.libwebsockets.org>
抄送: huangkaicheng <huangkaicheng at huawei.com>; Chenyake <chenyake at huawei.com>
主题: Re: 回复: 回复: [Libwebsockets] 答复: A question about libwebsockets dns resolve

On 5/11/20 7:56 AM, o_O凌雲 wrote:
> Hi,
>       I have made some changes to lws to limit wait time , and I make 
> mychanges.diff as your said. please help to review my code. thanks. I 
> add "PENDING_TIMEOUT_DNS_RESOLVER_TRY" to limit wait time. and using 
> "onevalid.bogus.warmcat.com" to test.see more in attachments.
>       huangkaicheng.

Thanks.  I could look at it and quickly see what's changed... basically what you're trying to do in there is not unreasonable.  But there's a lot of added / cut-and-pasted code introduced, the client connection path has already become overcomplicated and needs refactoring and cleaning rather than more code piled on.

I made a different patch that repurposes the timeout sul in the wsi to protect the connect similar to the lws_set_timeout() approach.  But instead of using the normal timeout flow, since it's pre connect() it sets a different callback that can directly call into connect3 and go to the next DNS result.  I checked this with blackhole.bogus.warmcat.com
( blackhole twice and one correct IP) and onevalid.bogus.warmcat.com (some 127.0.0.x and one correct IP) and he seems to act well.  For he waits for 20s (the default timeout in the context info) and then tries the next.

$ ./bin/lws-minimal-http-client --server onevalid.bogus.warmcat.com -d
1039 -m
$ ./bin/lws-minimal-http-client --server blackhole.bogus.warmcat.com -d
1039 -m


Please give it a try.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: websockets.txt
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20200511/2e685365/attachment-0001.txt>

More information about the Libwebsockets mailing list