I updated springboot from 3.2.8 to 3.4.1, my redis-server run with password and I can startup springboot-3.2.8 successfully. but failed in 3.4.1. I changed nothing, only updated springboot from 3.2.8 to 3.4.1
Caused by: org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.translateException(LettuceConnectionFactory.java:1858)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1789)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1586)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.lambda$getConnection$0(LettuceConnectionFactory.java:1566)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.doInLock(LettuceConnectionFactory.java:1527)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1563)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:1249)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:1055)
at org.springframework.data.redis.core.RedisConnectionUtils.fetchConnection(RedisConnectionUtils.java:195)
at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:144)
at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:105)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:398)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:378)
at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:117)
at org.springframework.data.redis.core.DefaultValueOperations.set(DefaultValueOperations.java:199)
at com.xsrcb.xyr.common.core.redis.RedisCache.setCacheObject(RedisCache.java:31)
at com.xsrcb.xyr.system.service.impl.SysConfigServiceImpl.loadingConfigCache(SysConfigServiceImpl.java:163)
at com.xsrcb.xyr.system.service.impl.SysConfigServiceImpl.init(SysConfigServiceImpl.java:40)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMethod.invoke(InitDestroyAnnotationBeanPostProcessor.java:457)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:401)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:219)
... 34 common frames omitted
Caused by: org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool
at org.springframework.data.redis.connection.lettuce.LettucePoolingConnectionProvider.getConnection(LettucePoolingConnectionProvider.java:104)
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1787)
... 57 common frames omitted
Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to 127.0.0.1/<unresolved>:6379
at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:63)
at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:41)
at io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:354)
at io.lettuce.core.RedisClient.connect(RedisClient.java:219)
at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.lambda$getConnection$1(StandaloneConnectionProvider.java:112)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:112)
at org.springframework.data.redis.connection.lettuce.LettucePoolingConnectionProvider.lambda$getConnection$0(LettucePoolingConnectionProvider.java:93)
at io.lettuce.core.support.ConnectionPoolSupport$RedisPooledObjectFactory.create(ConnectionPoolSupport.java:196)
at io.lettuce.core.support.ConnectionPoolSupport$RedisPooledObjectFactory.create(ConnectionPoolSupport.java:186)
at org.apache.commons.pool2.BasePooledObjectFactory.makeObject(BasePooledObjectFactory.java:71)
at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:566)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:306)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:233)
at io.lettuce.core.support.ConnectionPoolSupport$1.borrowObject(ConnectionPoolSupport.java:107)
at io.lettuce.core.support.ConnectionPoolSupport$1.borrowObject(ConnectionPoolSupport.java:102)
at org.springframework.data.redis.connection.lettuce.LettucePoolingConnectionProvider.getConnection(LettucePoolingConnectionProvider.java:99)
... 58 common frames omitted
Caused by: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.
at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:151)
at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:120)
at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:124)
at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:115)
at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:749)
at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:684)
at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:601)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1357)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:868)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
Comment From: snicoll
It is impossible for us to know what could go wrong based on your description. If you want support, you'll have to provide more details. Please create a small sample from start.spring.io where you connect to redis successfully prior to Spring Boot 3.4 that then fail when you upgrade to 3.4.
Comment From: clinker
@Mashazhou Upgrade to Lettuce 6.5.1.
Comment From: f981545521
springboot 3.4.1 , redis_version 5.0.14 and redis password seted
spring:
data:
redis:
database: 1
host: 127.0.0.1
port: 6379
timeout: 5000
lettuce:
pool:
max-active: 8
max-wait: -1
max-idle: 8
min-idle: 0
password: foobared
package com.example.demo;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
@SpringBootTest
class Demo1ApplicationTests {
@Autowired
private RedisTemplate redisTemplate;
@Test
void contextLoads() {
final Object a = redisTemplate.opsForValue().get("A");
System.out.println(a);
}
}
when use database: 0, success when use database: 1, faield error message: Caused by: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.
Comment From: snicoll
@f981545521 thank you for trying to help but code in text does not form a sample. If you want us to consider it, please share an actual sample we can run. You can attach a zip file here or push the code to a GitHub repository.
Comment From: benname
I also encountered this issue, but as suggested by @clinker, manually upgrading to version 6.5.1 can resolve it. The 6.4.1 version currently used by 3.4.1 may have some problems.
Comment From: snicoll
With nobody able to give a sample, I've reported that to the Lettuce team. Please subscribe to https://github.com/redis/lettuce/issues/3104 as they may have more questions about your setup I don't have (I've tried to reproduce the problem and didn't manage to).
Comment From: snicoll
We got some feedback from the Lettuce team. They're going to backport a fix and release 6.4.2 so I've re-scoped this issue in that direction.
Comment From: snicoll
For those affected, please give Spring Boot 3.4.2-SNAPSHOT a try (available from https://repo.spring.io/snapshot) in an hour or so. If that still doesn't work, please report back to the Redis team.
Comment From: uorhsohk
We had also the same issue, and upgrading lettuce to 6.5.2.RELEASE fixed our issue.