Quantcast
Channel: DaniWeb Solved Topics
Viewing all articles
Browse latest Browse all 576

Bad gateway using resttemplate

$
0
0

Hi have 2springboot applications running on ports 8085 and 8084. When I try to use RestTemplate to try to connect from one service to another, I get a BadGateway 502 exception.

Below is the stacktrace

head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.17.9</center>
</body>
</html>
]] with root cause

org.springframework.web.client.HttpServerErrorException$BadGateway: 502 Bad Gateway: [<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.17.9</center>
</body>
</html>
]
    at org.springframework.web.client.HttpServerErrorException.create(HttpServerErrorException.java:108) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:186) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:125) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
    at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
    at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:782) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:740) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:674) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:612) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]

Any reason why I might be getting this.

Below is the method call to the service

   ResponseEntity<List<String>> quoteResponse = restTemplate.exchange("http://localhost:8085/rest/db" + userName, HttpMethod.GET,
                null,
                new ParameterizedTypeReference<List<String>>() {
                });

Viewing all articles
Browse latest Browse all 576

Trending Articles