大脑系统偶尔NoHttpResponseException错误,
httpclient-4.4.1.jar
初步诊断为是对方服务器关闭了http连接,而己方仍在用这个连接请求数据
http1.1默认是长连接的,多个请求可以在一个连接中传输,但对方服务器会关闭空闲的连接。
需要进一步确认,http连接策略,和tcp连接。
要主动关闭默认http1.1d长连接导致的过期连接和限制链接
新增连接长连接超时策略,ConnectionKeepAliveStrategy
和开启
.evictExpiredConnections()//设置这两项,会开启定时任务清理过期和闲置的连接 .evictIdleConnections(IDLE_TIME, TimeUnit.MILLISECONDS)
同时新增失败重发策略,对于NoHttpResponseException异常进行重发。
CLIENT = HttpClients.custom()
.setConnectionTimeToLive(ALIVE_TIME, TimeUnit.MILLISECONDS)
.setKeepAliveStrategy(keepAliveStrategy)
.setConnectionManager(connecManager)
.setRetryHandler(retryHandler)
.evictExpiredConnections()//设置这两项,会开启定时任务清理过期和闲置的连接
.evictIdleConnections(IDLE_T