skip to Main Content

I am struggling to find what could be wring here; need help.
I am using spring-data-redis 2.4.1

RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration()
redisStandaloneConfiguration.setHostname(hostname)
redisStandaloneConfiguration.setPort(6379)
redisStandaloneConfiguration.setPassword("password")

I then create lettuceClientConfigurationBuilder and specify clientName

I then use lettuceClientConfiguration and redisStandaloneConfiguration to create ClientConnectionFactory.

However, when we call getConnection() on the connection Factory, we get

WrongPass Invalid username-password pair

The same set of username-password works with Redis-CLI on cmd prompt.

Is there is something wrong in the way I am using in my java application?

Any pointer/hint towards solving this would be greatly appreciated.

2

Answers


  1. Chosen as BEST ANSWER

    I had mistaken username for clientname set on LettuceClientConfigurationBuilder but username had to be specified on the redisstandaloneconfiguratuon. This works for me; also please note acl was introduced only after lettuce 2.4.1 so any prior version will not work.

    redisStandaloneConfiguration.setUsername(connectionFactoryConfigs.getUserName());


  2. Spring Boot configures LettuceConnectionFactory for you, you can specify the connection params on the application.properties file.

    spring.redis.database=0
    spring.redis.host=localhost
    spring.redis.port=6379
    spring.redis.password=yourPassword
    spring.redis.timeout=60000
    

    If you wanna do it programmatically, set the spring.redis.password in application.properties and try this:

    @Configuration
    class AppConfig {
    
      @Bean
      public LettuceConnectionFactory redisConnectionFactory() {
    
        return new LettuceConnectionFactory(new RedisStandaloneConfiguration("server", 6379));
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search