Below is the endpoint that receives the request and sends the response. Just before the "return" statement, I am printing out everything but I see the 504 first around 29 seconds later. It is as if the client is waiting for ~29 seconds and decides to throw 504 but the back end prints out the response later on depending on how complex the search is.
I have tried suggestions on Spring RestTemplate timeout and added the below code to my main application class. No luck!
@Bean
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
return restTemplateBuilder
.setConnectTimeout(Duration.ofMillis(35000))
.setReadTimeout(Duration.ofMillis(35000))
.build();
}
I do not see any issues with the logs, I am using the below ones for logging.
logging.level.root=ERROR
logging.level.org.springframework.web=WARN
logging.level.org.hibernate=ERROR
@PostMapping("/doSomething")
public ResponseEntity<ResultData> getRequest(@RequestBody RequestData requestData) {
try {
ResultData result = resultService.doSomethingHere(requestData);
System.out.println("\nresult: " + result.toString());
return new ResponseEntity<>(result, HttpStatus.OK);
} catch (NoSuchElementException e) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
Is there any other solution out there? Thanks