predixy icon indicating copy to clipboard operation
predixy copied to clipboard

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

Open kalpanathanneeru opened this issue 5 years ago • 4 comments

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 avatar Aug 07 '20 06:08 kalpanathanneeru

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)

kalpanathanneeru avatar Aug 07 '20 07:08 kalpanathanneeru

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

caojiajun avatar Mar 01 '21 11:03 caojiajun

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

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

sxy19930616 avatar Jul 08 '22 09:07 sxy19930616

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

huangjiasingle avatar Oct 21 '22 07:10 huangjiasingle