2

I have two Spring Boot REST application they talk with each other.

ProjectA, getTest rest service sometimes it takes a minute. It calls from projectB.

  @PostMapping(value = "/test")
  public ResponseEntity<Map<byte[], List<String>>> getTest(
      @RequestBody ObjectDTO configDto) {
    try {

      HashMap<byte[], List<String>> testMap =
          serviceImpl.test(configDto);

      if (!testMap.isEmpty())
        return new ResponseEntity<>(testMap, HttpStatus.CREATED);
      else return new ResponseEntity<>(testMap, HttpStatus.NO_CONTENT);

    } catch (Exception e) {      
      return ResponseEntity.badRequest().build();
    }
  }

ProjectB which calls the API above.

@PostMapping(value = "/getTest")
  @Async
  public ResponseEntity<Map<byte[], List<String>>> getTest(
      @RequestBody Config config) {
    try {
        Map<byte[], List<String>> val = serviceImpl.testConfig(config);
        return new ResponseEntity<>(val, HttpStatus.CREATED);       
    } catch (Exception e) {
      return ResponseEntity.badRequest().build();
    }
  }

It works locally but when I run on prod it always returns after 6.2s:

upstream request timeout

I have already increased the timeout on the properties with the config below on Project B, but did not work.

server.tomcat.connection-timeout=120000
spring.mvc.async.request-timeout=120000

so the question is how to fix a 504 Gateway Timeout Error

Update:

Fixed by setting a timeout on ambassador .yaml file below.

apiVersion: getambassador.io/v2
kind:  Mapping
metadata:
  name:  ambassador-header-mapping
  namespace: x
spec:
  prefix: /
  timeout_ms: 60000
  service: dummyservice:8080
  ambassador_id: ambassador-x
  headers:
    X-Forwarded-Proto: https
    Host: dummyhost
volkangurbuz
  • 259
  • 1
  • 4
  • 14

1 Answers1

2

It looks like you have additional proxy server which have own timouts config.