我试图通过一些代理服务器访问一些内容,但我得到:
<Errno::ETIMEDOUT: Connection timed out - connect(2)>
我修改了代码并尝试增加超时,如下所示:
require 'open-uri'
require 'net/http'
response = Net::HTTP::Proxy(proxy_ip, proxy_port).get_response(uri.host, uri.path)
response.start(uri.host) do |http|
http.open_timeout = 5
http.read_timeout = 10
end
现在它无法识别open_timeout
和start
undefined method `open_timeout=' for #<Net::HTTPOK 200 OK readbody=true>>
undefined method `start..
有什么帮助吗?