获取RestTemplate(连接重置)尽管一切都正确

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

我正在使用 Spring Boot RestTemplate 来调用 REST API。

在 PROD 上,我遇到以下异常:

org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://<host>/v2/graphql": Connection reset; nested exception is java.net.SocketException: Connection reset
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:602)

客户端的请求到达网关,网关也转发给服务器。服务器已成功处理请求,但连接在不到 5 秒内被重置。

这些是 RestTemplate 的 http 配置:

connectionRequestTimeoutMs: 3000
connectTimeoutMs: 3000
readTimeoutMs: 3000
maxConnectionsTotal: 100
maxConnectionsPerRoute: 100

总共 2300 个请求中,只有 8 个请求因连接重置错误而失败,但我想了解为什么会发生这种情况。

任何帮助将不胜感激。预先感谢!

spring-boot resttemplate httpconnection spring-resttemplate connection-reset
1个回答
0
投票

你能解决这个问题吗?如果是的话请告诉我答案

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