Search code examples
springredisspring-data-redislettuceredis-sentinel

Redis Sentinel Authentication using Lettuce+SpringDataRedis


I have the redis sentinels configured in my local running at 2 different ports 10001 and 10002. I have the sentinel authentication setup for the same.

Redis sentinel configuration

port 10001
bind 127.0.0.1
requirepass password
sentinel myid qwqsffhdhjyutsfgsfg4656767ifdfgtw4tgerhj
sentinel deny-scripts-reconfig yes
sentinel monitor mymaster 127.0.0.1 7777 2
sentinel auth-pass mymaster password

Version of jars used

Spring-data-redis : 2.0.10.RELEASE

Lettuce (io.lettuce.lettuce-core) : 5.0.5.RELEASE

Upon trying to connect to the redisSentinelConfiguration, I keep getting the NOAUTH Authentication REquired error

RedisSentinelConfiguration using Spring DI

<bean id="redisSentinelConfiguration" class="org.springframework.data.redis.connection.RedisSentinelConfiguration" p:password="#{T(org.springframework.data.redis.connection.RedisPassword).of('password')}"> 
        <constructor-arg type="java.lang.String" value="mymaster"></constructor-arg> 
        <constructor-arg type="java.util.Set"> <set value-type="java.lang.String"> 
        <value>127.0.0.1:10001</value> <value>127.0.0.1:10002</value> 
        </set> </constructor-arg> </bean>

ERROR:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisException: java.util.concurrent.ExecutionException: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.
10:38:37,980 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1699)
10:38:37,980 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573)
10:38:37,980 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
10:38:37,980 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
10:38:37,980 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
10:38:37,980 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
10:38:37,980 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
10:38:37,980 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759)
10:38:37,980 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
10:38:37,980 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:200)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:171)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:234)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at java.lang.Thread.run(Thread.java:748)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.jboss.threads.JBossThread.run(JBossThread.java:320)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72) Caused by: org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisException: java.util.concurrent.ExecutionException: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:966)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:934)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:786)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:300)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration$EnableRedisKeyspaceNotificationsInitializer.afterPropertiesSet(RedisHttpSessionConfiguration.java:284)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1758)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1695)
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72)   ... 31 more
10:38:37,981 INFO  [stdout] (ServerService Thread Pool -- 72) Caused by: io.lettuce.core.RedisException: java.util.concurrent.ExecutionException: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.RedisClient.lambda$getSocketAddressSupplier$9(RedisClient.java:720)
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.ConnectionBuilder.socketAddress(ConnectionBuilder.java:132)
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.AbstractRedisClient.initializeChannelAsync(AbstractRedisClient.java:251)
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.RedisClient.connectStatefulAsync(RedisClient.java:318)
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.RedisClient.connectStandaloneAsync(RedisClient.java:276)
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.RedisClient.connectStandalone(RedisClient.java:252)
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.RedisClient.connect(RedisClient.java:202)
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:56)
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:959)
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   ... 37 more
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72) Caused by: java.util.concurrent.ExecutionException: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
10:38:37,982 INFO  [stdout] (ServerService Thread Pool -- 72)   at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1915)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.RedisClient.lookupRedis(RedisClient.java:728)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.RedisClient.getSocketAddress(RedisClient.java:670)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.RedisClient.lambda$getSocketAddressSupplier$9(RedisClient.java:713)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   ... 45 more
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72) Caused by: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:118)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:109)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:598)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:556)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:508)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
10:38:37,984 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
10:38:37,985 INFO  [stdout] (ServerService Thread Pool -- 72)   at java.lang.Thread.run(Thread.java:748)

The google refereneces were not helping out in resolving this issue. Any helping hand to resolve the issue would be grateful


Solution

  • I upgraded the Spring-data-redis jar to 2.2.2.RELEASE and Lettuce jar to 5.2.1.RELEASE and that fixed the issue.

    There was issue with the lower version of Spring-data-redis jars where the sentinel password is not set properly in the lettuceConverters class which was fixed in the 2.2.2.RELEASE version.