最近寫了一個服務通過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
