2

I have the following code:

#!/usr/bin/env ruby

require 'net/http'

token = File.read("code.txt")
uri = URI("https://private.http.server.with.self.signed.certs")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
retjson = http.get("/api/conf/"+token)
puts retjson.body

and this works fine on my macbookpro13 mid 2010 8GB ram.

The same code on my new macbookpro15 mid 2014 16GB raises the following exception:

/Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/openssl/buffering.rb:174:in `sysread_nonblock': end of file reached (EOFError)
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/openssl/buffering.rb:174:in `read_nonblock'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/protocol.rb:141:in `rbuf_fill'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:2563:in `read_status_line'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:2552:in `read_new'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:1320:in `block in transport_request'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:1317:in `catch'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:1317:in `transport_request'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:1294:in `request'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:1287:in `block in request'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:746:in `start'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:1285:in `request'
from /Users/lc/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:1027:in `get'
from a.rb:10:in `<main>'

on both machines i have the same installation of ruby 1.9.3-p551 and the same gems.

If I remove the File.read line, then exception magically disappears, like this:

#!/usr/bin/env ruby

require 'net/http'

# token = File.read("code.txt")
token = '56f3052f84e9b73c46df21c7d91620dc'
uri = URI("https://private.http.server.with.self.signed.certs")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
retjson = http.get("/api/conf/"+token)
puts retjson.body

Googling around I found that net/http has some random behaviour depending on concurrency level, but I'm missing the point.

Any suggestion or pointer ?

Thanks in advance Luca

Luca
  • 315
  • 4
  • 13

0 Answers0