I am getting 504 Gateway Time-out issue Spring Boot Rest call using HTTP GET call for heavy record(more than 80K), I am calling other service to get data using RestTemplate object resClient, code as below:
public ResponseEntity<String> getData(String endPointUrl, Map<String, Object> parameterMap, String smToken) throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
headers.add("Cookie", smToken);
//headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<Map<String, Object>> entity = new HttpEntity<Map<String, Object>>(parameterMap, headers);
ResponseEntity<String> responseEntity = null;
try {
SSLUtil.turnOffSslChecking();
LOGGER.info("Start call to end point : " +endPointUrl+ " at :"+ (new Date().toString()) );
//resClient.getMessageConverters()
//.add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
responseEntity = resClient.exchange(endPointUrl, HttpMethod.POST, entity,String.class);
LOGGER.info("End of call to end point : " +endPointUrl+ " at :"+ (new Date().toString()) );
LOGGER.debug("Response from end point: " + responseEntity);
} catch (Exception e) {
LOGGER.error("Exception while making a http call to " + endPointUrl,e);
throw e;
}
return responseEntity;
}
While debugging I am seeing Response from other service call It takes more than 4 minutes, but rather than waiting it by that time to get response it use to come out only after 3 minutes. How can we make it to wait for response coming from other service call?
I tried to resolve this issue with increasing timeout time to 5 minutes using attribute server.connection-timeout=300000 in application.properties, but I am getting empty response. I am not sure If this is right approach or not. Please help me on this issue.
504 Gateway Time-out issue is generally thrown by proxy server that means server is closing connection. If client close connection then you will get Connectiontimeout error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With