Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
NijatShahverdiyev opened this issue Jun 21, 2024 · 3 comments

Comments

@NijatShahverdiyev
Copy link

NijatShahverdiyev commented Jun 21, 2024

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.
    @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<String, Object> commonRedisTemplate() {
        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
        redisTemplate.setKeySerializer(stringRedisSerializer);
        redisTemplate.setConnectionFactory(redisConnectionFactory());
        return redisTemplate;
    }

    @Bean("cacheManager")
    public CacheManager cacheManager() {
        Map<String, RedisCacheConfiguration> cacheConfigurations = new HashMap<>();
        RedisSerializer<Object> 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
Copy link
Collaborator

tishun commented Jun 23, 2024

I think you might be running into #1232 , see comment #1232 (comment)

Could you please let me know if this helped?

@NijatShahverdiyev
Copy link
Author

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

@tishun
Copy link
Collaborator

tishun commented Jun 25, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants