Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Ruby 标准库来创建持久连接:
Net::HTTP.new(host, port)
闲置一段时间后,ruby 会自行关闭连接吗?
是的。MRI Ruby 的默认值为 60 秒。
http = Net::HTTP.new(host, port) http.read_timeout # -> 60
如果您希望连接不超时,您可以设置read_timeout为nil
read_timeout
nil
http.read_timeout = nil