項目讀取數據,一直出現 Closing connections idle longer than 30 SECONDS,卡死現象。
我的是在讀取oracle數據的時候出現這種錯誤。
可以參考這篇文章
https://blog.csdn.net/qq_36856975/article/details/78184893
項目獲取雲之家的數據,寫的demo在main方法里面執行沒有問題,集成到自己公司的項目中,使用的是SSM框架,每當去獲取數據的時候控制台一直跳:
14:05:25,954 INFO [STDOUT] [PoolingHttpClientConnectionManager] : Closing expired connections 14:05:25,954 INFO [STDOUT] [PoolingHttpClientConnectionManager] : Closing connections idle longer than 30 SECONDS
雖然對於我獲取數據沒影響,但是保不准后期不會存在其他風險,還是嘗試關閉好。並且一直反復的彈送看着煩。
獲取雲之家數據的請求代碼(部分,需要全部的自己去找):
//獲取個人信息 保密的為公司對應的key文件密鑰
HttpResponse<JsonNode> jsonResponsePerson = Unirest .post(person_getall_url) .header("Content-Type", "application/x-www-form-urlencoded") .field("eid", "保密") .field("nonce", UUID.randomUUID().toString()) .field("data",EncryptUtils.encryptWithEncodeBase64UTF8(jsonData.toString(), key)).asJson();
關閉方法:
1. Unirest.shutdown() ;
如果使用這種我發現,它真的就停止了,也就是說我不重啟tomcat,再次去訪問的時候它取不到數據,那肯定不符合我的要求
2. 在 log4j.xml 里面配置如下一段代碼。(上面的英文是解釋)
You may use com.mashape.unirest.http.options.Options.refresh(); to enable Unirest again or just modify log4j to change the log level of org.apache.http.impl.conn.PoolingHttpClientConnectionManager from DEBUG.
<logger name="org.apache.http.impl.conn.PoolingHttpClientConnectionManager"> <level value="WARN"/> <appender-ref ref="MyLogFile"/> </logger>