I upgraded spring boot to 3.1.1 version and I get this error from Redis NOAUTH HELLO must be called with the client

huangapple go评论79阅读模式
英文:

I upgraded spring boot to 3.1.1 version and I get this error from Redis NOAUTH HELLO must be called with the client

问题

我最近将我的Spring Boot项目升级到版本3.1.1,我配置了Redis如下:

@Bean
public ReactiveRedisConnectionFactory redisFirstConnectionFactory() {
    var redisConf = new RedisStandaloneConfiguration();
    redisConf.setHostName(host);
    redisConf.setPort(port);
    redisConf.setPassword(password);
    redisConf.setDatabase(0);
    return new LettuceConnectionFactory(redisConf,
            LettuceClientConfiguration
                    .builder()
                    .commandTimeout(Duration.ofSeconds(10))
                    .build());
}

@Bean
public ReactiveStringRedisTemplate redisTemplate(ReactiveRedisConnectionFactory cf) {
    return new ReactiveStringRedisTemplate(cf);
}

但是当我启动应用程序时,我得到以下异常:

2023-07-17 13:59:17,781 [boundedElastic-1] WARN  org.springframework.boot.actuate.data.redis.RedisReactiveHealthIndicator [,] - Redis health check failed
org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis
    ...
Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to localhost/<unresolved>:6379
    ...
Caused by: io.lettuce.core.RedisCommandExecutionException: NOAUTH HELLO must be called with the client already authenticated, otherwise the HELLO AUTH <user> <pass> option can be used to authenticate the client and select the RESP protocol version at the same time
    ...

我可以使用该密码连接到Redis,使用RedisInsight工具。Redis版本为6.2.6。

如果您需要任何信息,请告诉我添加到问题中。

英文:

I recently upgraded my spring boot project to version 3.1.1, I configured the Redis like the following:

@Bean
public ReactiveRedisConnectionFactory redisFirstConnectionFactory() {
    var redisConf = new RedisStandaloneConfiguration();
    redisConf.setHostName(host);
    redisConf.setPort(port);
    redisConf.setPassword(password);
    redisConf.setDatabase(0);
    return new LettuceConnectionFactory(redisConf,
            LettuceClientConfiguration
                    .builder()
                    .commandTimeout(Duration.ofSeconds(10))
                    .build());
}


@Bean
public ReactiveStringRedisTemplate redisTemplate(ReactiveRedisConnectionFactory cf) {
    return new ReactiveStringRedisTemplate(cf);
}

But when I start the application I get the following Exception:

 2023-07-17 13:59:17,781 [boundedElastic-1] WARN  org.springframework.boot.actuate.data.redis.RedisReactiveHealthIndicator [,] - Redis health check failed
org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.translateException(LettuceConnectionFactory.java:1602)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1533)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1358)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1341)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedReactiveConnection(LettuceConnectionFactory.java:1083)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getReactiveConnection(LettuceConnectionFactory.java:479)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getReactiveConnection(LettuceConnectionFactory.java:105)
	at reactor.core.publisher.MonoSupplier.call(MonoSupplier.java:67)
	at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:227)
	at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
	at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to localhost/<unresolved>:6379
	at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:78)
	at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:56)
	at io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:350)
	at io.lettuce.core.RedisClient.connect(RedisClient.java:216)
	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.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1531)
	... 14 more
Caused by: io.lettuce.core.RedisCommandExecutionException: NOAUTH HELLO must be called with the client already authenticated, otherwise the HELLO AUTH <user> <pass> option can be used to authenticate the client and select the RESP protocol version at the same time
	at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:147)
	at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:116)
	at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:120)
	at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:111)
	at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:63)
	at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:747)
	at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:682)
	at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:599)
	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:1410)
	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:919)
	at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:800)
	at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:499)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:397)
	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)
	... 1 more

I can connect to Redis with that password using RedisInsight.
Redis version 6.2.6

If you need anything please tell me to add to question.

答案1

得分: 0

我不知道为什么Spring Boot 尝试使用自动配置来配置它的Redis。

我必须将以下内容添加到application.properties中:

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
英文:

I don't know why spring boot was trying to configure it's redis using auto configuration

I have to add this to application.properties

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration

huangapple
  • 本文由 发表于 2023年7月17日 18:38:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76703643.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定