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