我正在使用 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 个请求因连接重置错误而失败,但我想了解为什么会发生这种情况。
任何帮助将不胜感激。预先感谢!
你能解决这个问题吗?如果是的话请告诉我答案