org.redisson.client.RedisConnectionClosedException: succesfully sent, but channel has been closed!

本文介绍了解决Redisson客户端在使用EVAL命令时遇到RedisConnectionClosedException的问题。通过升级Redisson版本并调整连接参数,特别是增加pingConnectionInterval的值,有效避免了因长时间未操作而导致的连接关闭。
报错内容

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);
}
2025-09-26 10:28:40.093 [main] INFO [][c.huawei.foundation.commons.startup.event.ContainerComponent.643] begin to destroy component dataSourceStartup 2025-09-26 10:28:40.094 [main] INFO [][com.huawei.cube.rt.discovery.console.ConsoleDiscoveryClient.66] Shutting down 'ConsoleDiscoveryClient'... 2025-09-26 10:28:40.095 [main] INFO [][com.huawei.cube.rt.discovery.console.ConsoleDiscoveryClient.68] Shut down of 'ConsoleDiscoveryClient' succesfully! 2025-09-26 10:28:40.095 [main] INFO [][c.h.c.rt.loadbalancer.supplier.HealthCheckInstanceSupplier.81] LoadBalancer-HealthCheck is closed! 2025-09-26 10:28:40.096 [main] INFO [][c.h.c.r.loadbalancer.client.DefaultLoadBalancerClientFactory.84] The loadblancerClient 'disoveryClientLoadBalancer' is closed 2025-09-26 10:28:40.096 [main] WARN [][com.obs.services.AbstractClient.103] client closing 2025-09-26 10:28:40.097 [main] INFO [][com.obs.log.AccessLogger.103] 2025-09-26 10:28:34 274|main|info|com.obs.services.internal.utils.RestUtils$DefaultObsDns|<init>|line:488|use Default Dns\n2025-09-26 10:28:34 300|main|info|com.obs.services.AbstractClient|init|line:78|Storage|1|HTTP+XML|ObsClient||||2025-09-26 10:28:34|2025-09-26 10:28:34|||0|\n2025-09-26 10:28:34 301|main|warn|com.obs.services.AbstractClient|init|line:97|[OBS SDK Version=3.24.12];[Endpoint=http://s3-kp-kwe.his-beta.huawei.com:80/];[Access Mode=Path]\n2025-09-26 10:28:40 097|main|warn|com.obs.services.AbstractClient|close|line:448|client closing 2025-09-26 10:28:40.106 [main] WARN [][com.obs.services.AbstractClient.103] client closed 2025-09-26 10:28:40.107 [main] INFO [][com.obs.log.AccessLogger.103] 2025-09-26 10:28:40 106|main|warn|com.obs.services.AbstractClient|close|line:451|client closed 2025-09-26 10:28:40.112 [main] INFO [][SdkLog.85] [11.0.0][aa471ceeaecdfcd6559dd71a8b50cf23] Stopping iamTimer heartbeat 2025-09-26 10:28:40.112 [main] INFO [][SdkLog.85] [11.0.0][aa471ceeaecdfcd6559dd71a8b50cf23] IamTimer heartbeat has stopped 2025-09-26 10:28:40.119 [main] INFO [][org.apache.catalina.core.StandardService.168] Stopping service [Tomcat] 2025-09-26 10:28:40.123 [main] INFO [][com.huawei.cube.rt.web.xss.XssFilter.112] destroy XssFilter 2025-09-26 10:28:40.127 [main] INFO [][com.huawei.cube.api.context.RequestContextHolder.204] RequestContextFactory is 'class com.huawei.cube.rt.context.DefaultRequestContextFactory' 2025-09-26 10:28:40.136 [main] WARN [][org.apache.catalina.loader.WebappClassLoaderBase.168] The web application [deliverable#gateway] appears to have started a thread named [Caffeine-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:\n java.base/jdk.internal.misc.Unsafe.park(Native Method)\n java.base/java.util.concurrent.locks.LockSupport.park(LockSupport.java:371)\n java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:519)\n java.base/java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3780)\n java.base/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3725)\n java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1712)\n java.base/java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:435)\n java.base/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1070)\n java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)\n java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n java.base/java.lang.Thread.run(Thread.java:1583) 2025-09-26 10:28:40.137 [main] WARN [][org.apache.catalina.loader.WebappClassLoaderBase.168] The web application [deliverable#gateway] appears to have started a thread named [spectator-gauge-polling-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:\n java.base/jdk.internal.misc.Unsafe.park(Native Method)\n java.base/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:269)\n java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1763)\n java.base/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)\n java.base/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)\n java.base/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1070)\n java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)\n java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n java.base/java.lang.Thread.run(Thread.java:1583) 2025-09-26 10:28:40.162 [main] INFO [][o.s.b.autoconfigure.logging.ConditionEvaluationReportLogger.82] \n\nError starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2025-09-26 10:28:40.225 [main] ERROR [][org.springframework.boot.SpringApplication.858] Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'getOnlineWordService': Unsatisfied dependency expressed through field 'wordCreateService': Error creating bean with name 'outLine': Unsatisfied dependency expressed through field 'requirementService': Error creating bean with name 'requirementService': Unsatisfied dependency expressed through field 'requirementClient': Error creating bean with name 'requirementClient': Injection of autowired dependencies failed at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:788) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:768) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:146) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:509) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1459) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:606) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1221) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1187) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1123) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:987) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:753) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1362) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1351) at com.huawei.cbgit.onlinedocsmgmt.MainApplication.main(MainApplication.java:37) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:102) at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:64) at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:40) Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'outLine': Unsatisfied dependency expressed through field 'requirementService': Error creating bean with name 'requirementService': Unsatisfied dependency expressed through field 'requirementClient': Error creating bean with name 'requirementClient': Injection of autowired dependencies failed at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:788) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:768) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:146) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:509) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1459) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:606) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:2011) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1975) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeanMap(DefaultListableBeanFactory.java:1897) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1836) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1709) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1643) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:785) ... 27 common frames omitted Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'requirementService': Unsatisfied dependency expressed through field 'requirementClient': Error creating bean with name 'requirementClient': Injection of autowired dependencies failed at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:788) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:768) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:146) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:509) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1459) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:606) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1698) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1643) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:785) ... 45 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requirementClient': Injection of autowired dependencies failed at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:515) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1459) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:606) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1698) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1643) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:785) ... 58 common frames omitted Caused by: org.springframework.util.PlaceholderResolutionException: Could not resolve placeholder 'j2c.requirementReqKey.password' in value "${j2c.requirementReqKey.password}" <-- "${requirement.appkey}" at org.springframework.util.PlaceholderResolutionException.withValue(PlaceholderResolutionException.java:81) at org.springframework.util.PlaceholderParser$ParsedValue.resolve(PlaceholderParser.java:423) at org.springframework.util.PlaceholderParser.replacePlaceholders(PlaceholderParser.java:128) at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:118) at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:114) at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:293) at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:264) at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:186) at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:970) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1665) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1643) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:785) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:768) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:146) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:509) ... 68 common frames omitted
09-27
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值