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

huangkaicheng huangkaicheng at huawei.com
Mon May 11 13:30:40 CEST 2020


Hi, 
   I update the code of master, and set "timeout in the context info" time is 5s(default timeout (secs): 5). and it seem that it does not take effect. See more in attachment. 

   huangkaicheng

-----邮件原件-----
发件人: 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
(5.5.5.5 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 5.5.5.5 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

https://libwebsockets.org/git/libwebsockets/commit?id=461ea6e013040d0a299f34e77dabf4de8ae7e445

Please give it a try.

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


More information about the Libwebsockets mailing list