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

原文地址:https://www.cnblogs.com/tangyin/p/9951181.html