0

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

Cugomastik
  • 911
  • 13
  • 22
  • how do you call this WS ? via which tool ? – DEV Aug 07 '23 at 14:25
  • The request is sent via the Client. It works well with Postman. I have checked timeout settings on Proxy but nothing appears for 30 seconds. – Cugomastik Aug 07 '23 at 14:30
  • if the request works fine with postman, that means you have a proxy or a middle with a 30s timeout – DEV Aug 07 '23 at 14:32
  • that is what I thought aswell but there is no indication of any timeout settings for 30 sec on the proxy. – Cugomastik Aug 07 '23 at 14:44
  • it could be related that your service is taking too much time, comment this line `resultService.doSomethingHere(requestData);` and retry, see if it's working this time. – muhammed ozbilici Aug 07 '23 at 15:21

0 Answers0