I have some code that is attempting to make a RestTemplate call to a REST API on another server:
String url = "http://$authUrl:$authPort/cdpe/users/current";
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.add("Cookie", rdgLogin.getName() + "=" + rdgLogin.getValue());
requestHeaders.add("Cookie", jsessionId.getName() + "=" + jsessionId.getValue());
RestTemplate restTemplate = new RestTemplate();
HttpEntity requestEntity = new HttpEntity(null, requestHeaders);
ResponseEntity<String> resp = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
The server is up and running on a different machine "restserver" on port 8080. I've verified that it's up and running and waiting for connections.
When the above code executes I get a ConnectionRefused exception. Connection refused http://restserver:8080/cdpe/users/current. Usually this means the url is wrong or the server is not running. However, I can perform a curl command with the same URL on the same machine:
curl http://restserver:8080/cdpe/users/current
And I can get a response. Which leads me to believe there is something wrong with my RestTemplate call. Also, I can execute the same code on the same machine as the restserver and it works correctly. Any idea what I'm doing wrong?
I'm an idiot. I had typoed the URL in the $authUrl portion of the code in such a way that it was really, really hard to detect. Developer fail.