SpringBoot连接redis报错:exception is io.lettuce.core.RedisException: java.io.IOException: 远程主机强迫关闭了一个现有的连接

一、解决思路

(1).检查redis的配置是否正确

spring    
    redis:
        host: localhost
        port: 6379
        password: 123456
        database: 0
        timeout: 60s
        ## springboot2.0之后将连接池由jedis改为lettuce
        lettuce:
          pool:
            max-idle: 30
            max-active: 8
            max-wait: 10000
            min-idle: 10

(2).同时配置redis.conf中 tcp-keepalive时间为60s;redis-3.2.1版本默认300,设置60后上述问题不在出现

posted @ 2022-08-17 09:03  奋--斗  阅读(1083)  评论(0编辑  收藏  举报