Skip to content

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

@yiichou

Description

@yiichou

文档中提到:

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 秒.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions