-1

I think I have read all topics related to this subject, but still no solution. I am using:

  • RubyMine 2017.2.4
  • Ruby 2.4.1
  • Rails 5.1.0
  • Savon

When I connect in my rails console with Savon to a server, I get the following error:

Errno::ECONNRESET: An existing connection was forcibly closed by the remote host. - SSL_connect

This is the code I use:

wsdlUrl = 'https://some.server.com/ws/schema/Echo.wsdl'
licenseKey = '1234567890'

client = Savon.client(wsdl: wsdlUrl,
                  log:true,
                  ssl_verify_mode: :none)

response = client.call(:echo, 
                        message: { licenseKey: licenseKey,
                                   value: 'Hello World'})

puts "\nResult \"#{response.body[:echo_response][:value]}\" was returned"

I have tried to following:

  • Download the ca-bundle.crt and added to my system environment (and restart
    everything)
  • Updated my gems
  • Reinstall Ruby, Rails and RubyMine
  • Created a new app and copied code
  • added "require openssl" to the code
  • added the following code:

    require 'open-uri'
    require 'net/https'
    module Net
      class HTTP
        alias_method :original_use_ssl=, :use_ssl=
        def use_ssl=(flag)
           path = ( Rails.env == "development") ? "lib/ca-bundle.crt" : "/usr/lib/ssl/certs/ca-certificates.crt"
           self.ca_file = Rails.root.join(path).to_s
           self.verify_mode = OpenSSL::SSL::VERIFY_PEER
           self.original_use_ssl = flag
         end
       end
     end
    

Just nothing is working anymore.

The strange this is this:

When I run the rails (development) console, and I enter the code above I get the ssl_connect error. When I change some code in RubyMine, and DON'T restart the console, I won't get any errors. When I rerun the Rails Console, I get the ssl-connect error again.

Does anyone know where I can look

EDIT 1: I found out that if I put above code in a document (echo.rb) it will work when I call the document in the terminal as: ruby echo.rb

jww
  • 97,681
  • 90
  • 411
  • 885
Jerry
  • 198
  • 15
  • does it work from a script? – Steffen Roller Oct 17 '17 at 19:19
  • It does work when I call the script from the terminal. I placed the code in a document echo.rb. When I run ruby echo.rb it will work... – Jerry Oct 17 '17 at 19:50
  • sorry, can't help with Rails. – Steffen Roller Oct 17 '17 at 21:10
  • `openssl s_client -connect some.server.com:443 -servername so.server.com` return *`gethostbyname failure`*. Perhaps you should provide accurate information if you want help. Or, ask one of your team members if you can't provide the information. – jww Oct 18 '17 at 01:26
  • Since Stack Overflow hides the Close reason from you: This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting. – jww Oct 18 '17 at 01:28

1 Answers1

0

For all that are having the same problem:

first

 $ gem install 'http' (or add gem 'http' to your Gemfile and install)

then add this in your code:

 require 'http'
Jerry
  • 198
  • 15