Search code examples
rubyrest-client

How can I get a more information than `Errno::ECONNRESET: An existing connection was forcibly closed by the remote host. - SSL_connect`


I have some ruby test code that hits an API endpoint and sends it JSON.

RestClient.post(url, json, :content_type => :json, :accept => :json) { |response, request, result|
  @last_response = response
}

It works ittermittently sometimes giving this error.

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

What can I get more information about what is going on?


Solution

  • By setting RESTCLIENT_LOG=stdout environment variable you will see RestClient debug data in the terminal. Or you can replace stdout with a file path to write it out to a log file.

    The reason may be an invalid SSL cert or just a flaky API endpoint that sometimes disconnects before returning a response.