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);
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM