0

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.

Joshua
1,1264 gold badges17 silver badges32 bronze badges
asked Dec 21, 2020 at 16:07
1
  • Where is the username set? Commented Dec 21, 2020 at 16:52

2 Answers 2

3

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));
 }
}
answered Dec 22, 2020 at 10:06
Sign up to request clarification or add additional context in comments.

Comments

0

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());

answered Dec 24, 2020 at 4:18

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.