Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文档中关于 timeout 的说明有歧义 #156

Open
yiichou opened this issue Oct 28, 2016 · 3 comments
Open

文档中关于 timeout 的说明有歧义 #156

yiichou opened this issue Oct 28, 2016 · 3 comments

Comments

@yiichou
Copy link
Contributor

yiichou commented Oct 28, 2016

文档中提到:

Wechat server timeout setting

Stability various even for Tencent wechat server, so setting a long timeout may needed, default is 20 seconds if not set.

通常来说,用户都会以为默认是请求超过 20 秒就会被判定为超时,并中断

但实际上:

# lib/wechat/http_client.rb line 9 in wechat.gem
# timeout = 20 by default
@httprb = HTTP.timeout(:global, write: timeout, connect: timeout, read: timeout)

# lib/http/timeout/global.rb in http.gem
def initialize(*args)
  super
  reset_counter
end

# To future me: Don't remove this again, past you was smarter.
def reset_counter
  @time_left = connect_timeout + read_timeout + write_timeout
  @total_timeout = time_left
end

也就是说,实际允许的超时时间最大可能是设定值的 3 倍,即 60 秒.

@Eric-Guo
Copy link
Owner

欢迎PR,这部分timeout之前是基于rest client的,后来换到http后没更新,现在http的timeout控制确实精细了不少。

@daggerjames
Copy link
Contributor

借楼问下... @Eric-Guo 为什么把rest-client切换到http?因为我也在做类似的封装0.0

@Eric-Guo
Copy link
Owner

Eric-Guo commented Nov 2, 2016

速度快,可以保持http连接。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants