【发布时间】:2023-03-15 02:28:01
【问题描述】:
OpenSSL::SSL::SSLErrorWaitReadable "read would block" 是什么意思?
我收到错误 OpenSSL::SSL::SSLErrorWaitReadable 和消息 read would block。我认为这是因为超时,但我找不到有关该主题的任何文档。
谁能帮我弄清楚是什么原因造成的?还有我可以做些什么来防止这个问题?
不时产生此错误的代码:
data = {hello: "world"}
path = "https://example.com/api"
uri = URI.parse(path)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = (uri.scheme == "https")
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
request = Net::HTTP::Post.new(uri.request_uri)
request.body = Oj.dump(data)
request["Content-Type"] = "application/json"
begin
response = http.request(request) #this line produces the error.
rescue
return nil
end
我在 osx 10.10.3 上使用 ruby 版本 2.1.5p273 和 openssl 版本 1.0.1i。
Versions are found using the commandruby -v -ropenssl -rfiddle -e 'puts Fiddle::Function.new(Fiddle.dlopen(nil)["SSLeay_version"], [Fiddle::TYPE_INT], Fiddle::TYPE_VOIDP).call(0)'
感谢@bayendor
【问题讨论】: