title: Redis client Lettuce command timeout versus socket timeout
body: <p>We have  defined Lettuce client connection factory to be able to connect to Redis  defining custom socket and command timeout:</p>
  
  <pre><code>@Bean
  LettuceConnectionFactory lettuceConnectionFactory() {
  
     final SocketOptions socketOptions = SocketOptions.builder().connectTimeout(socketTimeout).build();
     final ClientOptions clientOptions =
             ClientOptions.builder().socketOptions(socketOptions).build();
  
     LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
             .commandTimeout(redisCommandTimeout)
             .clientOptions(clientOptions).build();
     RedisStandaloneConfiguration serverConfig = new RedisStandaloneConfiguration(redisHost,
             redisPort);
  
     final LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory(serverConfig,
             clientConfig);
     lettuceConnectionFactory.setValidateConnection(true);
     return new LettuceConnectionFactory(serverConfig, clientConfig);
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Zyhhv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Zyhhv.png" alt="enter image description here"></a></p>
  
  <p>Lettuce documentation define default values:</p>
  
  <ul>
  <li>Default socket timeout is 10 seconds</li>
  <li>Default command timeout is 60 seconds</li>
  </ul>
  
  <p>If Redis service is down application must receive timeout in 300ms. Which value must be defined as the greatest value?</p>
  
  <p>Github example project: 
  <a href="https://github.com/cristianprofile/spring-data-redis-lettuce" rel="noreferrer">https://github.com/cristianprofile/spring-data-redis-lettuce</a></p>