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?