com.lambdaworks.redis.RedisException: Connection is closed

Spring JIRA | Ilayaperumal Gopinathan | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Currently, ModuleDeployer is a disposable bean. When the container context is closed, the ModuleDeployer bean is destroyed along with its associated common context and deployed modules. Issue arises, if the connectionfactory bean associated with the deployed modules' message bus bindings is destroyed before the ModuleDeployer bean, there is exception stacktrace (at least in case of Redis MessageBus) saying "Connection closed". Adding SmartLifecycle support to ModuleDeployer will make sure all the beans are destroyed during Lifecycle processor's stop() method before any of the singletonbeans are destroyed. The stacktrace (when using Redis MessageBus is): org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is com.lambdaworks.redis.RedisException: Connection closed at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:45) at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:35) at org.springframework.data.redis.connection.lettuce.LettuceConverters.toDataAccessException(LettuceConverters.java:158) at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:237) at org.springframework.data.redis.connection.lettuce.LettuceConnection.bRPop(LettuceConnection.java:1449) at org.springframework.data.redis.core.DefaultListOperations$12.inRedis(DefaultListOperations.java:154) at org.springframework.data.redis.core.AbstractOperations$ValueDeserializingRedisCallback.doInRedis(AbstractOperations.java:50) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:181) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:149) at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:84) at org.springframework.data.redis.core.DefaultListOperations.rightPop(DefaultListOperations.java:151) at org.springframework.data.redis.core.DefaultBoundListOperations.rightPop(DefaultBoundListOperations.java:92) at org.springframework.integration.redis.inbound.RedisQueueMessageDrivenEndpoint.popMessageAndSend(RedisQueueMessageDrivenEndpoint.java:178) at org.springframework.integration.redis.inbound.RedisQueueMessageDrivenEndpoint.access$300(RedisQueueMessageDrivenEndpoint.java:51) at org.springframework.integration.redis.inbound.RedisQueueMessageDrivenEndpoint$ListenerTask.run(RedisQueueMessageDrivenEndpoint.java:291) at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52) at java.lang.Thread.run(Thread.java:722) Caused by: com.lambdaworks.redis.RedisException: Connection closed at com.lambdaworks.redis.RedisAsyncConnection.await(RedisAsyncConnection.java:1079) at com.lambdaworks.redis.RedisConnection.await(RedisConnection.java:820) at com.lambdaworks.redis.RedisConnection.brpop(RedisConnection.java:101) at org.springframework.data.redis.connection.lettuce.LettuceConnection.bRPop(LettuceConnection.java:1447) ... 12 more 13:19:00,897 WARN Thread-5 support.DefaultLifecycleProcessor:257 - Failed to stop bean 'org.springframework.integration.redis.inbound.RedisInboundChannelAdapter#0' com.lambdaworks.redis.RedisException: Connection is closed at com.lambdaworks.redis.RedisAsyncConnection.dispatch(RedisAsyncConnection.java:1065) at com.lambdaworks.redis.pubsub.RedisPubSubConnection.unsubscribe(RedisPubSubConnection.java:82) at org.springframework.data.redis.connection.lettuce.LettuceSubscription.doUnsubscribe(LettuceSubscription.java:68) at org.springframework.data.redis.connection.util.AbstractSubscription.unsubscribe(AbstractSubscription.java:186) at org.springframework.data.redis.connection.util.AbstractSubscription.unsubscribe(AbstractSubscription.java:146) at org.springframework.data.redis.listener.RedisMessageListenerContainer$SubscriptionTask.cancel(RedisMessageListenerContainer.java:836) at org.springframework.data.redis.listener.RedisMessageListenerContainer.stop(RedisMessageListenerContainer.java:210) at org.springframework.integration.redis.inbound.RedisInboundChannelAdapter.doStop(RedisInboundChannelAdapter.java:127) at org.springframework.integration.endpoint.AbstractEndpoint.stop(AbstractEndpoint.java:100) at org.springframework.integration.endpoint.AbstractEndpoint.stop(AbstractEndpoint.java:115) at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:229) at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:51) at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:363) at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:202) at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:118) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:888) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:157) at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:809)

    Spring JIRA | 3 years ago | Ilayaperumal Gopinathan
    com.lambdaworks.redis.RedisException: Connection is closed
  2. 0

    Currently, ModuleDeployer is a disposable bean. When the container context is closed, the ModuleDeployer bean is destroyed along with its associated common context and deployed modules. Issue arises, if the connectionfactory bean associated with the deployed modules' message bus bindings is destroyed before the ModuleDeployer bean, there is exception stacktrace (at least in case of Redis MessageBus) saying "Connection closed". Adding SmartLifecycle support to ModuleDeployer will make sure all the beans are destroyed during Lifecycle processor's stop() method before any of the singletonbeans are destroyed. The stacktrace (when using Redis MessageBus is): org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is com.lambdaworks.redis.RedisException: Connection closed at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:45) at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:35) at org.springframework.data.redis.connection.lettuce.LettuceConverters.toDataAccessException(LettuceConverters.java:158) at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:237) at org.springframework.data.redis.connection.lettuce.LettuceConnection.bRPop(LettuceConnection.java:1449) at org.springframework.data.redis.core.DefaultListOperations$12.inRedis(DefaultListOperations.java:154) at org.springframework.data.redis.core.AbstractOperations$ValueDeserializingRedisCallback.doInRedis(AbstractOperations.java:50) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:181) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:149) at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:84) at org.springframework.data.redis.core.DefaultListOperations.rightPop(DefaultListOperations.java:151) at org.springframework.data.redis.core.DefaultBoundListOperations.rightPop(DefaultBoundListOperations.java:92) at org.springframework.integration.redis.inbound.RedisQueueMessageDrivenEndpoint.popMessageAndSend(RedisQueueMessageDrivenEndpoint.java:178) at org.springframework.integration.redis.inbound.RedisQueueMessageDrivenEndpoint.access$300(RedisQueueMessageDrivenEndpoint.java:51) at org.springframework.integration.redis.inbound.RedisQueueMessageDrivenEndpoint$ListenerTask.run(RedisQueueMessageDrivenEndpoint.java:291) at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52) at java.lang.Thread.run(Thread.java:722) Caused by: com.lambdaworks.redis.RedisException: Connection closed at com.lambdaworks.redis.RedisAsyncConnection.await(RedisAsyncConnection.java:1079) at com.lambdaworks.redis.RedisConnection.await(RedisConnection.java:820) at com.lambdaworks.redis.RedisConnection.brpop(RedisConnection.java:101) at org.springframework.data.redis.connection.lettuce.LettuceConnection.bRPop(LettuceConnection.java:1447) ... 12 more 13:19:00,897 WARN Thread-5 support.DefaultLifecycleProcessor:257 - Failed to stop bean 'org.springframework.integration.redis.inbound.RedisInboundChannelAdapter#0' com.lambdaworks.redis.RedisException: Connection is closed at com.lambdaworks.redis.RedisAsyncConnection.dispatch(RedisAsyncConnection.java:1065) at com.lambdaworks.redis.pubsub.RedisPubSubConnection.unsubscribe(RedisPubSubConnection.java:82) at org.springframework.data.redis.connection.lettuce.LettuceSubscription.doUnsubscribe(LettuceSubscription.java:68) at org.springframework.data.redis.connection.util.AbstractSubscription.unsubscribe(AbstractSubscription.java:186) at org.springframework.data.redis.connection.util.AbstractSubscription.unsubscribe(AbstractSubscription.java:146) at org.springframework.data.redis.listener.RedisMessageListenerContainer$SubscriptionTask.cancel(RedisMessageListenerContainer.java:836) at org.springframework.data.redis.listener.RedisMessageListenerContainer.stop(RedisMessageListenerContainer.java:210) at org.springframework.integration.redis.inbound.RedisInboundChannelAdapter.doStop(RedisInboundChannelAdapter.java:127) at org.springframework.integration.endpoint.AbstractEndpoint.stop(AbstractEndpoint.java:100) at org.springframework.integration.endpoint.AbstractEndpoint.stop(AbstractEndpoint.java:115) at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:229) at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:51) at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:363) at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:202) at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:118) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:888) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:157) at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:809)

    Spring JIRA | 3 years ago | Ilayaperumal Gopinathan
    com.lambdaworks.redis.RedisException: Connection is closed

    Root Cause Analysis

    1. com.lambdaworks.redis.RedisException

      Connection is closed

      at com.lambdaworks.redis.RedisAsyncConnection.dispatch()
    2. lettuce
      RedisPubSubConnection.unsubscribe
      1. com.lambdaworks.redis.RedisAsyncConnection.dispatch(RedisAsyncConnection.java:1065)
      2. com.lambdaworks.redis.pubsub.RedisPubSubConnection.unsubscribe(RedisPubSubConnection.java:82)
      2 frames
    3. Spring Data Redis
      RedisMessageListenerContainer.stop
      1. org.springframework.data.redis.connection.lettuce.LettuceSubscription.doUnsubscribe(LettuceSubscription.java:68)
      2. org.springframework.data.redis.connection.util.AbstractSubscription.unsubscribe(AbstractSubscription.java:186)
      3. org.springframework.data.redis.connection.util.AbstractSubscription.unsubscribe(AbstractSubscription.java:146)
      4. org.springframework.data.redis.listener.RedisMessageListenerContainer$SubscriptionTask.cancel(RedisMessageListenerContainer.java:836)
      5. org.springframework.data.redis.listener.RedisMessageListenerContainer.stop(RedisMessageListenerContainer.java:210)
      5 frames
    4. org.springframework.integration
      RedisInboundChannelAdapter.doStop
      1. org.springframework.integration.redis.inbound.RedisInboundChannelAdapter.doStop(RedisInboundChannelAdapter.java:127)
      1 frame
    5. Spring Integration Core
      AbstractEndpoint.stop
      1. org.springframework.integration.endpoint.AbstractEndpoint.stop(AbstractEndpoint.java:100)
      2. org.springframework.integration.endpoint.AbstractEndpoint.stop(AbstractEndpoint.java:115)
      2 frames
    6. Spring Context
      AbstractApplicationContext.doClose
      1. org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:229)
      2. org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:51)
      3. org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:363)
      4. org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:202)
      5. org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:118)
      6. org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:888)
      6 frames
    7. Spring Boot
      EmbeddedWebApplicationContext.doClose
      1. org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:157)
      1 frame
    8. Spring Context
      AbstractApplicationContext$1.run
      1. org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:809)
      1 frame