0

I have an application that makes an http request to another server instance, like this:

    http = Net::HTTP.new(ip_address, port)
    Net::HTTP::Post.new("/insert", 'Content-Type' => 'application/json')
    request.body(data)
    response = http.request(request)
    logger.info response 

It is supposed to communicate with another AWS internal instance of mine. It is working well and when the requested IP is not avaiable IT DOES timeout, like expected.

The problem is when I'm running this code on my local machine. My computer can't access this IP address, so I expected it to timeout or even raise an exception, but instead of this the program blocks completely trying to do the request and I can't even stop the server (the only way was by killing the process)!

How can I threat this case?

Casanova
  • 33
  • 6

1 Answers1

0

You could either wrap the code in an unless Rails.env.production? block, or add a line to /etc/hosts that maps the remote IP to 127.0.0.1 which should behave better.


Brian
  • 5,300
  • 2
  • 26
  • 32