Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOAUTH Authentication required #1543

Closed
An0nymous0 opened this issue Dec 2, 2020 · 4 comments
Closed

NOAUTH Authentication required #1543

An0nymous0 opened this issue Dec 2, 2020 · 4 comments
Labels
for: stackoverflow A question that is better suited to stackoverflow.com

Comments

@An0nymous0
Copy link

An0nymous0 commented Dec 2, 2020

Bug Report

Current Behavior

Connect to the low version of redis, prompt NOAUTH Authentication required.

Stack trace Caused by: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required. at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:137) ~[lettuce-core-6.0.0.RELEASE.jar:6.0.0.RELEASE] at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:110) ~[lettuce-core-6.0.0.RELEASE.jar:6.0.0.RELEASE] at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:120) ~[lettuce-core-6.0.0.RELEASE.jar:6.0.0.RELEASE] at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:111) ~[lettuce-core-6.0.0.RELEASE.jar:6.0.0.RELEASE] at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:59) ~[lettuce-core-6.0.0.RELEASE.jar:6.0.0.RELEASE] at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:704) ~[lettuce-core-6.0.0.RELEASE.jar:6.0.0.RELEASE] at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:639) ~[lettuce-core-6.0.0.RELEASE.jar:6.0.0.RELEASE] at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:560) ~[lettuce-core-6.0.0.RELEASE.jar:6.0.0.RELEASE] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.54.Final.jar:4.1.54.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.54.Final.jar:4.1.54.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.54.Final.jar:4.1.54.Final] ... 1 common frames omitted
RedisClient client = RedisClient.create(RedisURI.builder()
                .withHost("172.18.150.9")
                .withPort(6379)
                .withPassword("laosiji123".toCharArray())
                .build());
StatefulRedisConnection<String, String> connection = client.connect();
RedisStringCommands sync = connection.sync();
String value = sync.get("test").toString();

Input Code

Input Code
        RedisClient client = RedisClient.create(RedisURI.builder()
                .withHost("172.18.1.1")
                .withPort(6379)
                .withPassword("laosiji".toCharArray())
                .build());
        StatefulRedisConnection<String, String> connection = client.connect();
        RedisStringCommands sync = connection.sync();
        String value = sync.get("test").toString();

Expected behavior/code

Environment

  • Lettuce version(s): [e.g. 6.0.1.RELEASE]
  • Redis version: [e.g. 4.1.1]

Possible Solution

Additional context

@An0nymous0 An0nymous0 added the type: bug A general bug label Dec 2, 2020
@mp911de
Copy link
Collaborator

mp911de commented Dec 2, 2020

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem.

Attaching the debug log is also a good option.

@mp911de mp911de added status: waiting-for-feedback We need additional information before we can continue and removed type: bug A general bug labels Dec 2, 2020
@An0nymous0
Copy link
Author

An0nymous0 commented Dec 9, 2020

@mp911de
HELLO
The packet capture found that lettuce 6.x uses the RESP3 protocol to request the cloud server redis service 4.x by default, which resulted in unsupported. But I verified that the official redis4.0.11 is supported. Because what the cloud server returns is not that the RESP3 protocol does not support but the verification failed.

I solved it by manually specifying RESP2

RedisClient redisClient = RedisClient.create(RedisURI.Builder.redis("x.x.x.x", 6379).withPassword("laosiji123".toCharArray()).withDatabase(6).build());
redisClient.setOptions(ClientOptions.builder().protocolVersion(ProtocolVersion.RESP2).build());

lettuce 5.x -> cloud server redis
image
lettuce 6.x 0> cloud server redis
image

Official redis
image

@mp911de
Copy link
Collaborator

mp911de commented Dec 9, 2020

Thanks for the report. Lettuce 6 tries to auto-discover the protocol. If Redis responds with -ERR, then we fall back to RESP2. -NOAUTH on HELLO is considered an unknown scenario so we can't figure out what to do.

@Anricx
Copy link

Anricx commented Dec 29, 2021

Here is the best practice with spring boot

package com.chinaroad.parking.config;

import io.lettuce.core.ClientOptions;
import io.lettuce.core.protocol.ProtocolVersion;
import org.springframework.boot.autoconfigure.data.redis.LettuceClientConfigurationBuilderCustomizer;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;

@Configuration
public class SpringConfig implements LettuceClientConfigurationBuilderCustomizer {

    @Override
    public void customize(LettuceClientConfiguration.LettuceClientConfigurationBuilder clientConfigurationBuilder) {
        // manually specifying RESP2 
        clientConfigurationBuilder.clientOptions(ClientOptions.builder()
                .protocolVersion(ProtocolVersion.RESP2)
                .build());
    }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: stackoverflow A question that is better suited to stackoverflow.com
Projects
None yet
Development

No branches or pull requests

3 participants