gpt4 book ai didi

java - Spring Boot Rest 调用大量记录时出现 504 网关超时问题(超过 80K)

转载 作者:太空宇宙 更新时间:2023-11-04 09:45:31 26 4
gpt4 key购买 nike

我使用 HTTP GET 调用进行大量记录(超过 80K)时遇到 504 网关超时问题 Spring Boot Rest 调用,我正在使用 RestTemplate 对象 resClient 调用其他服务来获取数据,代码如下:

public ResponseEntity<String> getData(String endPointUrl, Map<String, Object> parameterMap, String smToken) throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
headers.add("Cookie", smToken);
//headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<Map<String, Object>> entity = new HttpEntity<Map<String, Object>>(parameterMap, headers);
ResponseEntity<String> responseEntity = null;
try {
SSLUtil.turnOffSslChecking();
LOGGER.info("Start call to end point : " +endPointUrl+ " at :"+ (new Date().toString()) );
//resClient.getMessageConverters()
//.add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
responseEntity = resClient.exchange(endPointUrl, HttpMethod.POST, entity,String.class);
LOGGER.info("End of call to end point : " +endPointUrl+ " at :"+ (new Date().toString()) );
LOGGER.debug("Response from end point: " + responseEntity);
} catch (Exception e) {
LOGGER.error("Exception while making a http call to " + endPointUrl,e);
throw e;
}

return responseEntity;
}

在调试时,我看到其他服务调用的响应需要 4 分钟以上的时间,但它并没有等到那时才获得响应,而是在 3 分钟后才出现。我们怎样才能让它等待来自其他服务调用的响应?

我尝试使用 application.properties 中的属性 server.connection-timeout=300000 将超时时间增加到 5 分钟来解决此问题,但我收到空响应。我不确定这是否是正确的方法。请帮助我解决这个问题。

最佳答案

504网关超时问题通常由代理服务器抛出,这意味着服务器正在关闭连接。如果客户端关闭连接,那么您将收到 Connectiontimeout 错误。

关于java - Spring Boot Rest 调用大量记录时出现 504 网关超时问题(超过 80K),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55466650/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com