title: spring boot Redis configuration - Connection failure occurred. Restarting subscription task after 5000 ms
body: <p>I have a following spring boot redis configuration.</p>
  
  <pre><code>@Configuration
  public class RedisConnectionConfiguration {
  @Bean
  public RedisTemplate&lt;String, Object&gt; redisTemplate() {
      RedisTemplate&lt;String, Object&gt; redisTemplate = new RedisTemplate&lt;String, Object&gt;();
      redisTemplate.setConnectionFactory(jedisConnectionFactory());
      return redisTemplate;
  }
  
  @Bean
  RedisConnectionFactory jedisConnectionFactory() {
      JedisConnectionFactory jedisConnectionFactory = null;
          jedisConnectionFactory = new JedisConnectionFactory();
          jedisConnectionFactory.setHostName(host);
          jedisConnectionFactory.setPort(port);
          jedisConnectionFactory.setTimeout(0);
          jedisConnectionFactory.setPassword(password);
          JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
  
  
          jedisPoolConfig.setMaxTotal(20);
          jedisPoolConfig.setMaxIdle(9000);
          jedisPoolConfig.setMinIdle(16);
          jedisPoolConfig.setTestOnBorrow(true);
          jedisPoolConfig.setTestOnReturn(true);
          jedisPoolConfig.setTestWhileIdle(true);
          jedisPoolConfig.setMinEvictableIdleTimeMillis(60000);
          jedisPoolConfig.setTimeBetweenEvictionRunsMillis(60000);
          jedisPoolConfig.setNumTestsPerEvictionRun(3);
          jedisPoolConfig.setBlockWhenExhausted(true);
          jedisConnectionFactory.setPoolConfig(jedisPoolConfig);
  
      return jedisConnectionFactory;
  }
  
  @Bean
  MessageListenerAdapter messageListener() {
      return new MessageListenerAdapter(eventListenerService);
  }
  
  @Bean
  ChannelTopic topic() {
      return new ChannelTopic(com.mds.core.common.Constants.REDIS_TOPIC_NAME);
  }
  
  @Bean
  RedisMessageListenerContainer redisContainer() {
      final RedisMessageListenerContainer container = new RedisMessageListenerContainer();
      container.setConnectionFactory(jedisConnectionFactory());
      container.addMessageListener(messageListener(), receiverTopic());
      container.setTaskExecutor(Executors.newFixedThreadPool(4));
      return container;
  }
  
  
  @Bean
  ChannelTopic receiverTopic() {
      return new ChannelTopic(com.mds.core.common.Constants.REDIS_FRONT_BACK_TOPIC_NAME);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This is redis version and port.</p>
  
  <p>Redis 4.0.6 (00000000/0) 64 bit
  Port: 6376</p>
  
  <p>This is spring application.yaml</p>
  
  <pre><code>spring:
    profiles: local, default
    mvc:
    view:
      prefix: /
      suffix: .jsp
  
    redis:
      host: 127.0.0.1
      password: welcome
      port: 6376
  </code></pre>
  
  <p>When I start the spring boot application, it boots fine, but a little later, I start getting the following errors. The following error doesn't stop. </p>
  
  <p>[pool-2-thread-1] ERROR requestId= o.s.d.r.l.RedisMessageListenerContainer 647 - Connection failure occurred. Restarting subscription task after 5000 ms</p>
  
  <p>I am just using the default redis configuration file which comes with the redis zip file. I only changed the password. </p>
  
  <p>But even though I get the error message, the spring web application works fine. The session is created and I have no problem using the web application on local machine.   I even tested it with clustered redis (3 instances) with haproxy(redis port: 6376). Basically, spring web application works fine with the clustered redis.</p>
  
  <p>But I don't think that I can deploy it into the production environment without figuring out the error message.</p>
  
  <p>Does anybody know why I am getting this?</p>
  
  <p>Thanks</p>