question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for Redis Sentinel authentication

See original GitHub issue

Bug Report

Current Behavior

I am trying to connect to the sentinel node of a Redis setup in AWS, and I am getting the message:

NOAUTH Authentication required.

Input Code

Just used a template for Spring Boot from start.spring.io with redis my properties are

spring:
  redis:
    password: ***********
    sentinel:
      master: redis-master
      nodes:
        - redis-sentinel.host

Expected behavior/code

It should connect without a problem.

Environment

  • Lettuce version(s): 5.1.4.RELEASE, 5.1.5.RELEASE
  • Redis version: 5.0.1

Possible Solution

I think the problem is that from 5.0.1 and on they added authentication on the Sentinel and that’s why it’s failing. For more info check Redis 5 Release Notes

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Pramit2512commented, Jun 23, 2022

After some help i was able to connect to redis as :

    RedisClient redisClient = RedisClient.create();

        LOG.info("created the redis client");

        RedisURI source = RedisURI.Builder
                .sentinel(getSentinelHost_1(), getSentinelPort_1())
                .withSentinel(getSentinelHost_2(), getSentinelPort_2())
                .withSentinel(getSentinelHost_3(), getSentinelPort_3())
                .withSentinelMasterId(getMasterName()).withPassword(getMasterPassword())
                .build();

        for (RedisURI sentinel : source.getSentinels()) {
            sentinel.setPassword(getSentinelPassword());
        }

        StatefulRedisMasterReplicaConnection<String, String> connection = MasterReplica.connect(redisClient, StringCodec.UTF8,
                source);

        connection.setReadFrom(ReadFrom.REPLICA_PREFERRED);

        LOG.info("created the redis connection");
1reaction
cdekkercommented, Oct 3, 2019

@mp911de How is this to be used with Spring Boot? I am running into the same issue where I have a password on both my Sentinel and Redis node (same password), but upgrading to lettuce-core 5.2.0.RELEASE does not solve the issue.

I have this in my gradle file:

implementation 'org.springframework.boot:spring-boot-starter-data-redis'
compile 'org.springframework.session:spring-session-data-redis:2.1.8.RELEASE'
compile group: 'io.lettuce', name: 'lettuce-core', version: '5.2.0.RELEASE'

When running gradle dependencies, I see that lettuce-core version is successfully overridden from 5.1.8. to 5.2.0:

+--- org.springframework.boot:spring-boot-starter-data-redis -> 2.1.8.RELEASE
|    +--- org.springframework.boot:spring-boot-starter:2.1.8.RELEASE (*)
|    +--- org.springframework.data:spring-data-redis:2.1.10.RELEASE (*)
|    \--- io.lettuce:lettuce-core:5.1.8.RELEASE -> 5.2.0.RELEASE (*)

My application properties has this:

spring.session.store-type=redis

spring.redis.password=mypassword
spring.redis.sentinel.master=mymaster
spring.redis.sentinel.nodes=redis-sentinel-hostname:26379

Yet, when starting up, I still get the same exception: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.

Read more comments on GitHub >

github_iconTop Results From Across the Web

High availability with Redis Sentinel
Popular client libraries have Sentinel support, but not all. ... To use Sentinel with password-only authentication, add the requirepass configuration ...
Read more >
Redis Sentinel Authentication - Stack Overflow
Redis servers configured as Sentinels do not support AUTH by design. Be sure to place Sentinels on a secure network. – Cy Rossignol....
Read more >
Add support for sentinel authentication #594 - predis ... - GitHub
We really need to find a way to specify a common password for sentinels so that it's handled in a different way from...
Read more >
Support Sentinel authentication through `requirepass` - GitLab
Problem to solve. As of now, it is not possible to enforce client authentication at Sentinel level, even if Redis auth is enabled....
Read more >
Redis source · High availability · Administration · Help · GitLab
Step 3. Configuring the Redis Sentinel instances ... Sentinel is a special type of Redis server. It inherits most of the basic configuration...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found