Errno::ECONNRESET (Connection reset by peer - SSL_connect)

Karamat picture Karamat · Apr 12, 2013 · Viewed 15.2k times · Source

our code is generating an exception on heroku server since the last few hours. It was working okay before that on the same server with the same code.

The exception is Errno::ECONNRESET (Connection reset by peer - SSL_connect) heroku server.

The line of code on which we are getting exception is:

response = http.request(request, json_data) 

What could be the possible reason/solution for this exception?

  def self.get_response_from_v2(url,json_data)
  http = Net::HTTP.new(url.host, 443)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  request = Net::HTTP::Post.new(url.path, {'Content-Type' => 'application/json'})
  request.basic_auth url.user, url.password if url.user
  response = http.request(request, json_data)
  result = JSON.parse(response.body)
  result
end

We have tried the solutions:

SSL_connect error when accessing Shopify API with rubygem

Answer