redis報錯:java.net.SocketException: Broken pipe (Write failed); nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Broken pipe (Write failed)


   最近寫了一個服務通過springboot構建,里面使用了redis作為緩存,發布到服務器運行成功,但是有時候會報redis的錯誤:org.springframework.data.redis.RedisConnectionFailureException: java.net.SocketException: Broken pipe (Write failed); nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Broken pipe (Write failed)   

  在網上查了一下原因是因為redis的客戶端超時時間超時導致寫入失敗,然后我把配置文件的 timeout 參數設置為0 同時配置testOnReturn,testWhileIdle,testOnBorrow為true 這樣就沒有提示這樣的錯誤了

#客戶端超時時間
redis.timeout=0
#是否在從池中取出連接前進行檢驗,如果檢驗失敗,則從池中去除連接並嘗試取出另一個
redis.testOnBorrow=true  
#在空閑時檢查有效性, 默認false
redis.testWhileIdle=true  
#是否進行有效性檢查
redis.testOnReturn=true

 

 SpringBoot|MVC|SpringCloud

 技術交流QQ群號:216868740


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM