Java Spring boot-504网关超时

Java Spring boot-504网关超时,java,spring,rest,spring-boot,Java,Spring,Rest,Spring Boot,在下面的体系结构中,我们经常遇到一个问题(大部分是第一次)。 我们有一个应用程序X与一个调用外部API的应用程序Y通信。 有时,应用程序Y会调用它发回的外部API: <html><body><h1>504 Gateway Time-out</h1>The server didn't respond in time.\n</body></html> 以及修改rest模板超时值: private ClientHttpReq

在下面的体系结构中,我们经常遇到一个问题(大部分是第一次)。 我们有一个应用程序X与一个调用外部API的应用程序Y通信。 有时,应用程序Y会调用它发回的外部API:

<html><body><h1>504 Gateway Time-out</h1>The server didn't respond in time.\n</body></html>
以及修改rest模板超时值:

  private ClientHttpRequestFactory getRequestFactory() {
    HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
    factory.setReadTimeout(600000);
    factory.setConnectTimeout(600000);
    factory.setConnectionRequestTimeout(600000);
    return factory;
  }
引发错误的代码:

return CompletableFuture.supplyAsync(() -> {
    try {
        return restTemplate.exchange(uri, httpMethod, requestEntity, clazz);
    } catch (Exception e) {
        throw new CompletionException(e); // The exception we throw that contains the html code.
    }
});

有什么想法吗?

你解决了这个问题吗?
return CompletableFuture.supplyAsync(() -> {
    try {
        return restTemplate.exchange(uri, httpMethod, requestEntity, clazz);
    } catch (Exception e) {
        throw new CompletionException(e); // The exception we throw that contains the html code.
    }
});