redis / lettuce

Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
https://lettuce.io
MIT License
5.37k stars 960 forks source link

Caused by: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required. #2901

Closed NijatShahverdiyev closed 3 months ago

NijatShahverdiyev commented 3 months ago

Bug Report

Current Behavior

I have configured elttuce sentinel connection like this, but I got _**NOAUTH Authentication required.**_. PS: We are using sentinel headless on kubernetes. ```java @Bean public RedisConnectionFactory redisConnectionFactory() { RedisSentinelConfiguration sentinelConfig = new RedisSentinelConfiguration() .master(masterName); sentinelConfig.sentinel(host, port); sentinelConfig.setPassword(redisPassword); LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder() .commandTimeout(Duration.ofMillis(redisConnectionTimeout)) .readFrom(ReadFrom.REPLICA_PREFERRED) .clientOptions(ClientOptions.builder() .protocolVersion(ProtocolVersion.RESP2) .build()) .build(); return new LettuceConnectionFactory(sentinelConfig, clientConfig); } @Bean("commonRedisTemplate") public RedisTemplate commonRedisTemplate() { RedisTemplate redisTemplate = new RedisTemplate<>(); StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); redisTemplate.setKeySerializer(stringRedisSerializer); redisTemplate.setConnectionFactory(redisConnectionFactory()); return redisTemplate; } @Bean("cacheManager") public CacheManager cacheManager() { Map cacheConfigurations = new HashMap<>(); RedisSerializer kryoGenericSerializer = new KryoGenericSerializer<>(); RedisCacheConfiguration defaultCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig() .disableCachingNullValues() .serializeValuesWith(RedisSerializationContext .SerializationPair .fromSerializer(kryoGenericSerializer)); redisCacheConfigs.forEach((String cacheName, Long cacheTtlMinutes) -> cacheConfigurations.put(cacheName, defaultCacheConfiguration.entryTtl(Duration.ofMinutes(cacheTtlMinutes)))); return RedisCacheManager.builder(redisConnectionFactory()) .cacheDefaults(defaultCacheConfiguration) .withInitialCacheConfigurations(cacheConfigurations) .build(); } ```

Expected behavior/code

Environment

  • Lettuce version(s):6.3.2.RELEASE
tishun commented 3 months ago

I think you might be running into #1232 , see comment https://github.com/redis/lettuce/issues/1232#issuecomment-588132278

Could you please let me know if this helped?

NijatShahverdiyev commented 3 months ago

@tishun thanks a bunch, you saved my week)). I am done with this issue.

tishun commented 3 months ago

@tishun thanks a bunch, you saved my week)). I am done with this issue.

Happy to help. We should address this though, so that other people don't run into it.