What causes OpenSSL :: SSL :: SSLErrorWaitReadable "read will block"?

What does OpenSSL::SSL::SSLErrorWaitReadable "read would block" mean?

I get an OpenSSL::SSL::SSLErrorWaitReadable message with a read would block . I think this is due to timeouts, but I cannot find documentation on this.

Can someone help me figure out what causes this? Also, what can I do to prevent the problem?

The code that produces this error from time to time:

 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 

I am using ruby ​​version 2.1.5p273 and openssl version 1.0.1i on osx 10.10.3 .

Versions are found using the ruby -v -ropenssl -rfiddle -e 'puts Fiddle::Function.new(Fiddle.dlopen(nil)["SSLeay_version"], [Fiddle::TYPE_INT], Fiddle::TYPE_VOIDP).call(0)' Thanks @bayendor

+7
source share
1 answer

Could not play on my local machine. It works. Here is my version so that you can confirm your system? Or, if your Mac machine and you installed ruby ​​with the openssl and readline systems, this may lead to it becoming outdated. Try installing a new openssl and readline and create ruby, and then run the script again.

 % 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 

 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 
0
source share

All Articles