Ruby 什么原因导致OpenSSL::SSL::SSLErrorWaitReadable;“读会挡”吗;? OpenSSL::SSL::SSLErrorWaitReadable“readwillblock”是什么意思?
我收到错误消息Ruby 什么原因导致OpenSSL::SSL::SSLErrorWaitReadable;“读会挡”吗;? OpenSSL::SSL::SSLErrorWaitReadable“readwillblock”是什么意思?,ruby,net-http,Ruby,Net Http,我收到错误消息OpenSSL::SSL::SSLErrorWaitReadable,消息read将阻止。我想这是因为超时,但我找不到关于这个主题的任何文档 有人能帮我找出是什么引起的吗?我能做些什么来防止这个问题? 不时产生此错误的代码: data = {hello: "world"} path = "https://example.com/api" uri = URI.parse(path) http = Net::HTTP.new(uri.host, uri.port) http.use_
OpenSSL::SSL::SSLErrorWaitReadable
,消息read将阻止
。我想这是因为超时,但我找不到关于这个主题的任何文档
有人能帮我找出是什么引起的吗?我能做些什么来防止这个问题?
不时产生此错误的代码:
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
我在osx10.10.3
上使用ruby版本2.1.5p273
和openssl版本1.0.1i
ruby-v-ropenssl-rfiddle-e'放入Fiddle::Function.new(Fiddle.dlopen(nil)[“SSLeay_version”],[Fiddle::TYPE_INT],Fiddle::TYPE_VOIDP)。调用(0)
感谢@bayendor无法在我的本地机器上复制。它起作用了。这是我的版本,你能用你的系统确认吗?或者,如果您的机器是Mac,并且安装了ruby系统openssl和readline,则可能会因为它太旧而导致错误。尝试安装新的openssl和readline并构建ruby,然后再次执行脚本
% brew install openssl readline
% RUBY_CONFIGURE_OPTS="--enable-shared --with-readline-dir=$(brew --prefix readline) --with-openssl-dir=$(brew --prefix openssl)" rbenv install 2.0.0-p598
我使用ruby
2.1.5p273
,它似乎在mac osx 10.10.3上使用openssl版本1.0.1i
。如何使用openssl版本>1.0.2进行ruby构建?你仍然得到了错误?嗯,这可能会导致错误消失,但我真的很想知道错误的意思。这是源代码。我不太了解lib,但您将看到它是如何实现的。希望这有助于你的理解。谢谢:)其实我已经看过了,但是我想不出多少。再看一遍,我发现:这可能意味着某些东西正在使用同一个套接字进行写入,而另一些东西正在同时读取。。将调查
OS: MaxOSX 10.10.2
ruby: 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin12.0]
oj (2.12.9)
% ruby test.rb
OK
% cat test.rb
require 'uri'
require 'net/http'
require 'openssl'
require 'oj'
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.
puts('OK')
rescue
return nil
end