首页 > 解决方案 > 如何在 Spring Boot 中复制由对等方重置的连接?

问题描述

在我的生产环境中,我的服务器出现以下错误:

 Cannot forward to error page for request [/api/validation] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
org.apache.catalina.connector.ClientAbortException: java.io.IOException: Connection reset by peer

现在我创建了一个客户端并每秒生成 1000 个线程来调用它[/api/validation]。我得到的错误是

Exception in thread "Thread-9954" org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://localhost:7080/v1/name/validate": Timeout waiting for connection from pool; nested exception is org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool.

现在我想知道是什么原因造成的Connection reset by peer

据我所知,当客户端通过发送 RST 数据包中止连接时会发生此错误。我将客户端休息模板的套接字超时设置为 9000。我让服务器休眠约 15000 毫秒。现在服务器不应该得到Connection reset by peer,因为服务器尝试在 15 秒后发送响应,而我的客户端只等待大约 9 秒。我不应该得到错误吗?

同样在生产环境中,客户端的等待时间(Rest template socket time out)设置为大约 90 秒(超过服务器响应所需的时间)。为什么生产中会产生错误?

标签: spring-bootconnection-reset

解决方案


推荐阅读