Ruby app fails in https request on heroku.com

66 views Asked by At

I have a rails app which has been running on heroku for two years now without problems. And I have the following ruby code in a rake file.

require 'open-uri'
require 'json'

namespace :myapp do
    task :load_remote_data, [:user_id] => :environment do |t, args|
        events_url = "https://myapp.com/events"
        #returns json
        puts "Event url #{events_url}"
        #this gets printed ok
        result = JSON.parse(open(events_url).read)
        #open fails
        puts "Server result #{result}"
end

Error msg from Heroku console:

rake aborted!
SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A
/app/lib/tasks/load_remote_data.rake:13:in `block (2 levels) in <top (required)>'

It seems to be some sort problem with HTTPS request. This is Ruby version i am running on Heroku

heroku run ruby --version
Running `ruby --version` attached to terminal... up, run.2192
ruby 1.9.2p330 (2014-08-07 revision 47094) [x86_64-linux]

Any ideas what to change for this to be able to make HTTPS requests again.

1

There are 1 answers

0
locoboy On

This looks like your apps config doesn't like the version of SSL that your app is using. You might need to make sure that open-uri is sending the right version of SSL handshake, probably TLSv1.

I'm not personally aware of how to use open-uri but maybe you could use RestClient instead.