Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2229

RedisCommandExecutionException in Java Lettuce Redis client

$
0
0

I have a problem with a Java Lettuce Redis client with ACL: I get an io.lettuce.core.RedisCommandExecutionException: WRONGPASS invalid username-password pair or user is disabled exception.I have a Redis Docker container configured as follows:

My Dockerfile:

FROM redis:6.2.1COPY redis.conf /usr/local/etc/redis/redis.confCOPY users.acl /etc/redis/users.aclEXPOSE 6379CMD ["redis-server", "/usr/local/etc/redis/redis.conf"]

The redis.conf file is:

aclfile /etc/redis/users.acl

and the users.acl file is:

user myuser on +@all ~* >mypassworduser default off

I run the container with the command:

docker run -it -p 6379:6379 --name myredis myredis

My Java client is:

...import io.lettuce.core.RedisClient;import io.lettuce.core.api.StatefulRedisConnection;public class Main {    public static void main(String... args) {        try {            RedisClient redisClient = RedisClient.create("redis://myuser:mypassword@localhost");            StatefulRedisConnection<String, String> connection = redisClient.connect();            System.out.println("Connected to Redis");            connection.close();            redisClient.shutdown();        } catch (Exception e) {            e.printStackTrace();        } finally {            System.out.println("End!");        }    }}

When I try to run it, I get the error:

io.lettuce.core.RedisConnectionException: Unable to connect to localhost: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:234)    at io.lettuce.core.RedisClient.connect(RedisClient.java:207)    at io.lettuce.core.RedisClient.connect(RedisClient.java:192)    at [MY_PACKAGE].Main.main(Main.java:16)Caused by: io.lettuce.core.RedisCommandExecutionException: WRONGPASS invalid username-password pair or user is disabled.    at io.lettuce.core.ExceptionFactory.createExecutionException(ExceptionFactory.java:135)    at io.lettuce.core.ExceptionFactory.createExecutionException(ExceptionFactory.java:108)    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.CommandHandler.complete(CommandHandler.java:654)    at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:614)    at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:565)    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422)    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931)    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700)    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635)    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552)    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514)    at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050)    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:834)

What am I doing wrong? Thanks in advance.


Viewing all articles
Browse latest Browse all 2229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>