http://xiangai.taobao.com
http://shop148612228.taobao.com

Redis server response timeout (3000 ms) occured after 3 retry attempts. Command: (EXISTS), params: [

Redis server response timeout (3000 ms) occured after 3 retry attempts. Command: (EXISTS), params: [XXXX], channel: [id: 0xXXXX, L:/XXXXX.45.128:44772 - R:10.122.67.XX/10.122.67.56:6379]X

rg.redisson.client.RedisResponseTimeoutException: Redis server response timeout (3000 ms) occured after 3 retry attempts. Command: (HEXISTS), params: [com.dinsmooth.storehbase.schedule:entryTaskDelay, 1f15dcac-22b6-4865-92a5-a6452e6ae5c3:154], channel: [id: 0x4d120152, L:/10.255.2.30:52607 - R:172.16.0.211/172.16.0.211:6379] at org.redisson.command.RedisExecutor$3.run(RedisExecutor.java:362) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:682) at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:757) at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:485) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748)

 

误原因:客户端长时间未使用,服务端会断开

解决办法:redisson添加配置 

#连接间隔 心跳 pingConnectionInterval: 1000

 

使用代码配置:

package io.lenovo.ecai.portalorder.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.spring.data.connection.RedissonConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedissonConfig {
    /**
     * 设置redisson缓存工厂,由于下面的工厂都是用的是redisson所以注意配置redissonclient
     *
     * @param client
     * @return
     */
    @Bean(name = "redissonconnectionfactory")
    public RedissonConnectionFactory getfactory(RedissonClient client) {
        return new RedissonConnectionFactory(client);
    }

    /**
     * redis单机配置
     *
     * @return
     */
    public RedissonClient getclient() {
        Config config = new Config();

        config.useSingleServer().setAddress("redis://${spring.redis.host}:${spring.redis.port}")
                .setTimeout(1000)
                .setRetryAttempts(3)
                .setRetryInterval(1000)
                .setPingConnectionInterval(1000)//**此项务必设置为redisson解决之前bug的timeout问题关键*****
                .setDatabase(3);
        return Redisson.create(config);
    }
}

 

posted @ 2021-01-12 21:00  万事俱备就差个程序员  阅读(8059)  评论(1编辑  收藏  举报

http://xiangai.taobao.com
http://shop148612228.taobao.com
如果您觉得对您有帮助.领个红包吧.谢谢.
支付宝红包
微信打赏 支付宝打赏