Open yb opened 6 months ago
Hello @yb
感谢反馈,你是专业的! 我看看这个问题怎么处理,感觉不太好搞,应该是得引入 ctx 了。
If you think this repository is helpful, please share it with friends, thanks.
Hi @likexian
我现在使用 connect, err := net.DialTimeout("tcp", address, timeout)
这个方式重写了 whois func,可以解决连接时的 timeout 问题,但我不确定能否与你设计的 c.dialer
合并,仅供参考
Hello @likexian, I have opened a pull request to address this issue. It is not the cleanest way to address the problem, but might help provide a quick and dirty way forward. As suggested in the PR, we may need to make additional changes to SetTimout to make this a reliable change - but those changes might cause backwards compatibility issues with some uses of the whois package. I welcome feedback and understand if this is not the direction you would like to go in!
Hi @likexian,
我遇到了和 #37 相同的问题,经过测试和检查 whois.go 的源代码,我猜测:
SetTimeout()
只设置了c.timeout
,而c.dialer.Timeout
没有被更新,它在NewClient()
时已经被固定为 30 秒;c.dialer.Dial()
则 timeout 无效;之所以会得出这个猜测,是因为今晚我所在的网络无法连接到
whois.nic.work
这个服务器,以下为 ping 表现:然后看了一下 net 包中关于 Dialer.Timeout 的解释,好像确实与连接时的超时有关:
EDIT: 补充一个复现方法:
如此,即可复现 5 秒超时的设置并没起作用,连接
www.google.com:43
要等到 30 秒后才超时。由于这是第一次接触 go 语言,如果猜测错误,请见谅 感谢