Spring boot - 504网关超时

问题描述 投票:0回答:1

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

<html><body><h1>504 Gateway Time-out</h1>The server didn't respond in time.\n</body></html>

我们尝试在application.yml中设置此值

server:
    connection-timeout: 300000

并修改其余的模板超时值:

  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.
    }
});

任何的想法 ?

java spring rest spring-boot
1个回答
-1
投票

1)使用SoapUI检查时间 - 如果API是Soap API

如果您使用Wildfly,您可以更改超时。也许超时来自服务器。

© www.soinside.com 2019 - 2024. All rights reserved.