HttpClient中出现意外连接关闭

HttpClient中出现意外连接关闭,httpclient,apache-httpclient-4.x,connection-close,Httpclient,Apache Httpclient 4.x,Connection Close,在web应用程序中,我面临着HttpClient(版本4.5.2)的一个问题,我的意思是,以多线程的方式。在正常情况下,当连接请求到达时,将从池中租用一个连接,然后使用该连接,最后将其释放回池中,以便在将来的请求中再次使用,作为id为673890的连接状态日志的以下部分 15 Feb 2017 018:25:54:115 p-1-thread-121 DEBUG PoolingHttpClientConnectionManager:249 - Connection request: [route

在web应用程序中,我面临着HttpClient(版本4.5.2)的一个问题,我的意思是,以多线程的方式。在正常情况下,当连接请求到达时,将从池中租用一个连接,然后使用该连接,最后将其释放回池中,以便在将来的请求中再次使用,作为id为673890的连接状态日志的以下部分

15 Feb 2017 018:25:54:115 p-1-thread-121 DEBUG PoolingHttpClientConnectionManager:249 - Connection request: [route: {}->http://127.0.0.1:8080][total kept alive: 51; route allocated: 4 of 100; total allocated: 92 of 500]
15 Feb 2017 018:25:54:116 p-1-thread-121 DEBUG PoolingHttpClientConnectionManager:282 - Connection leased: [id: 673890][route: {}->http://127.0.0.1:8080][total kept alive: 51; route allocated: 4 of 100; total allocated: 92 of 500]
15 Feb 2017 018:25:54:116 p-1-thread-121 DEBUG DefaultManagedHttpClientConnection:90 - http-outgoing-673890: set socket timeout to 9000
15 Feb 2017 018:25:54:120 p-1-thread-121 DEBUG PoolingHttpClientConnectionManager:314 - Connection [id: 673890][route: {}->http://127.0.0.1:8080] can be kept alive for 10.0 seconds
15 Feb 2017 018:25:54:121 p-1-thread-121 DEBUG PoolingHttpClientConnectionManager:320 - Connection released: [id: 673890][route: {}->http://127.0.0.1:8080][total kept alive: 55; route allocated: 4 of 100; total allocated: 92 of 500]
在以我上面提到的正常方式多次使用上述连接(id 673890)之后,我注意到代码中发生了以下情况:

15 Feb 2017 018:25:54:130 p-1-thread-126 DEBUG PoolingHttpClientConnectionManager:249 - Connection request: [route: {}->http://127.0.0.1:8080][total kept alive: 55; route allocated: 4 of 100; total allocated: 92 of 500]
15 Feb 2017 018:25:54:130 p-1-thread-126 DEBUG PoolingHttpClientConnectionManager:282 - Connection leased: [id: 673890][route: {}->http://127.0.0.1:8080][total kept alive: 54; route allocated: 4 of 100; total allocated: 92 of 500]
15 Feb 2017 018:25:54:131 p-1-thread-126 DEBUG DefaultManagedHttpClientConnection:90 - http-outgoing-673890: set socket timeout to 9000
15 Feb 2017 018:25:54:133 p-1-thread-126 DEBUG DefaultManagedHttpClientConnection:81 - http-outgoing-673890: Close connection
15 Feb 2017 018:25:54:133 p-1-thread-126 DEBUG PoolingHttpClientConnectionManager:320 - Connection released: [id: 673890][route: {}->http://127.0.0.1:8080][total kept alive: 55; route allocated: 3 of 100; total allocated: 91 of 500]
日志显示连接被请求、租用、使用、关闭,然后释放回池中。所以,我的问题是为什么连接会关闭?为什么它在关闭后被释放到池中

我知道服务器可能会关闭连接,但情况不同。在这种情况下,连接是从池中租用的,被确定为过时,因此建立并使用了一个新的连接,但上面显示的日志显示了不同的行为


我知道HttpClient中连接关闭的两个原因。首先,由于KeepAliveTime已过期,因此因空闲而关闭。其次,由服务器关闭,这会使池中的连接过时。关闭连接还有其他原因吗?

根据Oleg Kalnichevski在HttpClient邮件列表中的回复,以及我所做的检查,发现问题是由于另一方发送的“Connection:close”头。另一个可能导致相同情况的原因是使用HTTP/1.0非持久性连接