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

Java redis cluster client is not able to connect to redis cluster through predixy proxy #116

Open
kalpanathanneeru opened this issue Aug 7, 2020 · 4 comments

Comments

@kalpanathanneeru
Copy link

Hi, While connecting to cluster mode redis server through predixy proxy using java redis cluster client trying to execute cluster nodes/cluster info commands to verify is redis in standalone or cluster mode .
But predixy is throwing error like ERR unknown command 'cluster'.
Is there any way we can solve this issue or workaround for it.

@kalpanathanneeru
Copy link
Author

kalpanathanneeru commented Aug 7, 2020

code snippet:

    String passwordkey = "demo12"; 
    RedisClusterClient client = RedisClusterClient.create("redis://"+passwordkey+"@100.192.5.6:7617/");
    StatefulRedisClusterConnection<String, String> connection = client.connect();
    connection.setReadFrom(ReadFrom.REPLICA_PREFERRED);
    System.out.println("Connected to Redis");

   
    RedisAdvancedClusterCommands<String, String> sync = connection.sync();
    sync.set("key", "value");
    System.out.println("get value:"+ sync.get("key").toString()); 

    connection.close();
    client.shutdown(); 

Error:
Aug 06, 2020 2:24:16 PM io.lettuce.core.cluster.topology.ClusterTopologyRefresh getNodeSpecificViews
WARNING: Cannot retrieve partition view from RedisURI [host='100.192.5.6', port=7617], error: java.util.concurrent.ExecutionException: io.lettuce.core.RedisCommandExecutionException: ERR unknown command 'cluster'
Aug 06, 2020 2:24:16 PM io.lettuce.core.cluster.topology.ClusterTopologyRefresh getNodeSpecificViews
WARNING: Cannot retrieve partition view from RedisURI [host='100.192.5.6', port=7617], error: java.util.concurrent.ExecutionException: io.lettuce.core.RedisCommandExecutionException: ERR unknown command 'cluster'
Exception in thread "main" io.lettuce.core.RedisException: Cannot retrieve initial cluster partitions from initial URIs [RedisURI [host='100.192.5.6', port=7617]]
at io.lettuce.core.cluster.topology.ClusterTopologyRefresh.tryFail(ClusterTopologyRefresh.java:144)
at io.lettuce.core.cluster.topology.ClusterTopologyRefresh.loadViews(ClusterTopologyRefresh.java:106)
at io.lettuce.core.cluster.RedisClusterClient.doLoadPartitions(RedisClusterClient.java:868)
at io.lettuce.core.cluster.RedisClusterClient.loadPartitions(RedisClusterClient.java:841)
at io.lettuce.core.cluster.RedisClusterClient.initializePartitions(RedisClusterClient.java:816)
at io.lettuce.core.cluster.RedisClusterClient.connect(RedisClusterClient.java:348)
at io.lettuce.core.cluster.RedisClusterClient.connect(RedisClusterClient.java:323)
at com.mycompany.app.App.main(App.java:24)
Caused by: io.lettuce.core.RedisCommandExecutionException: ERR unknown command 'cluster'
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:118)
at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:109)
at io.lettuce.core.cluster.topology.TimedAsyncCommand.complete(TimedAsyncCommand.java:52)
at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:59)
at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:680)
at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:640)
at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:591)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:792)
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)

@caojiajun
Copy link

使用了predixy代理之后,访问redis cluster就像访问单节点redis一样,因此你不能使用RedisClusterClient去连接predixy

@sxy19930616
Copy link

sxy19930616 commented Jul 8, 2022

使用了predixy代理之后,访问redis cluster就像访问单节点redis一样,因此你不能使用RedisClusterClient去连接predixy

那连接信息还写redis对应的信息么 如 ip:6379 而不是 ip:7617

@huangjiasingle
Copy link

但是有写开源库,如果是使用proxy的单个节点去链接使用的单节点模式,就会使用事务,而cluster又是不支持事物的,这就很尴尬了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants