Recommendations for configuring the connection between nancy service and server

I am working on a project where we have sites (developed with ruby ​​on rails) hosted on an Ubuntu server using tomcat. We want these sites to make HTTP requests to a service developed with Nancy. We have it working locally when the service is hosted on a machine that we can call on our network. However, we cannot make it work when we live. Here's an example call:

def get_call(routePath)
  started_at = Time.now
  enc_url = URI.encode("#{settings.service_endpoint}#{routePath}")
  uri = URI.parse(enc_url)
  http = Net::HTTP.new(uri.host, uri.port)   
  req = Net::HTTP::Get.new(uri.request_uri) 
  resp = http.request(req)
  logger.bench 'SERVICE - GET', started_at, routePath
  return resp if response_ok?(resp)
end

      

When working locally, the settings are as follows:

settings.service_endpoint = http://10.10.10.27:7820
routePath = /Customers

      

When we upload it to the server, we use the following:

settings.service_endpoint = http://127.0.0.1:24099
routePath = /Customers

      

We are currently receiving the following error:

SocketError at /register
initialize: name or service not know

      

with the following line highlighted:

resp = http.request(req)

      

We are totally wrong when calling the IP. It should be 127.0.0.1, localhost. 10.10.10.27 or something completely different? It's weird that we can make a GET call via telnet on our Ubuntu server (telnet 127.0.0.1 24099), so that means the server can make calls, but the site hosted on the server can't. Do I need to enable HTTP proxy (read some link to this, but not sure if needed).

Sorry if this is obvious, but we've never tried anything like this before, so it was all very puzzling. Any additional information required will just let me know.

+3


source to share


1 answer


We changed service_endpoint to localhost and it worked. Not sure if this is because he didn't like "http: //" or for some other reason. Any explanation as to why this is the case would be very helpful, just to let us know. Thank!



0


source







All Articles