报错内容
org.redisson.client.RedisConnectionClosedException: Command (EVAL), params: [if (redis.call(‘exists’, KEYS[1]) == 0) then redis.call(‘hset’, KEYS[1], ARGV[2], 1); redis.call('pe…, 1, lock:e98958002bc606383633cfcddcb2d3bd, 30000, 00b51efb-b1c6-4783-b877-12a7c2d966c0:95] succesfully sent, but channel [id: 0xcbe56471, L:0.0.0.0/0.0.0.0:52362 ! R:ip/ip.208:7000] has been closed!
org.redisson.client.RedisConnectionClosedException: Command (EVAL), params: [if (redis.call('exists', KEYS[1]) == 0) then redis.call('hset', KEYS[1], ARGV[2], 1); redis.call('pe..., 1, lock:e98958002bc606383633cfcddcb2d3bd, 30000, 00b51efb-b1c6-4783-b877-12a7c2d966c0:95] succesfully sent, but channel [id: 0xcbe56471, L:0.0.0.0/0.0.0.0:52362 ! R:ip/ip.208:7000] has been closed!
解决
pom
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.9.1</version>
</dependency>
redis版本
集群模式
原因
redis 的间隙过长,导致连接关闭
解决
https://github.com/redisson/redisson/issues/2268
设置ping的时长
pingConnectionInterval = 60000
@Bean
public RedissonClient getRedissonClient() {
Config config = new Config();
if (!org.apache.commons.lang3.StringUtils.isEmpty(slave)) {
config.useSentinelServers()
.setMasterName(masterName)
.setPassword("".equals(password) ? null : password)
.addSentinelAddress(getSlaves())
.setPingConnectionInterval(60000);
} else {
config.useSingleServer()
.setAddress("redis://" + host + ":" + port)
.setPassword("".equals(password) ? null : password)
.setPingConnectionInterval(60000);
}
return Redisson.create(config);
}