Connection to Redis cluster failed

799 views
Skip to first unread message

Roy Gill

unread,
Aug 24, 2015, 2:01:41 AM8/24/15
to Redis DB
I have setup Redis cluster in Google compute Engine by click to deploy option. Now i want to connect to this redis server from my node js code using 'ioredis' here is my code to connect to single instance of redis

var Redis = require("ioredis");

var store = new Redis(6379, 'redis-ob0g');//to store the keys
var pub =   new Redis(6379, 'redis-ob0g');//to publish a message to all workers
var sub =   new Redis(6379, 'redis-ob0g');//to subscribe a message 

var onError = function (err) {
    console.log('fail to connect to redis ',err);
};
store.on('error',onError);
pub.on('error',onError);
sub.on('error',onError);

And it worked. Now i want to connect to redis as cluster, so i change the code as

/**
 * list of server in replica set
 * @type {{port: number, host: string}[]}
 */
var nodes =[
    {   port: port,    host: hostMaster},
    {   port: port,    host: hostSlab1},
    {   port: port,    host: hostSlab2}
];
var store =  new Redis.Cluster(nodes);//to store the keys
var pub =   new Redis.Cluster(nodes);//to publish a message to all workers
var sub =    new Redis.Cluster(nodes);//to subscribe a message channel


Now it throw this error:

enter image description here



Here is my Redis cluster in my google compute console:

enter image description here

Jan-Erik Rediger

unread,
Aug 24, 2015, 4:34:12 AM8/24/15
to redi...@googlegroups.com
1. Always include errors as text. Images of errors are not searchable and not accessible.
2. You are not running Redis 3 in Cluster mode.
Your last error is "ERR unknown command 'cluster'" – The command is
unknown, and this error only happens on older Redis versions.

On Sun, Aug 23, 2015 at 10:25:26PM -0700, Roy Gill wrote:
> I have setup Redis cluster in Google compute Engine
> <http://console.developers.google.com/> by click to deploy
> <https://cloud.google.com/solutions/redis/click-to-deploy?hl=en> option.
> Now i want to connect to this redis server from my node js code using
> 'ioredis' here is my code to connect to single instance of redis
>
> var Redis = require("ioredis");
> var store = new Redis(6379, 'redis-ob0g');//to store the keysvar pub = new Redis(6379, 'redis-ob0g');//to publish a message to all workersvar sub = new Redis(6379, 'redis-ob0g');//to subscribe a message
> var onError = function (err) {
> console.log('fail to connect to redis ',err);};
> store.on('error',onError);
> pub.on('error',onError);
> sub.on('error',onError);
>
>
> And it worked. Now i want to connect to redis as cluster, so i change the code as
>
> /**
> * list of server in replica set
> * @type {{port: number, host: string}[]}
> */var nodes =[
> { port: port, host: hostMaster},
> { port: port, host: hostSlab1},
> { port: port, host: hostSlab2}];var store = new Redis.Cluster(nodes);//to store the keysvar pub = new Redis.Cluster(nodes);//to publish a message to all workersvar sub = new Redis.Cluster(nodes);//to subscribe a message channel
>
>
>
> Now it throw this error:
>
> [image: enter image description here] <http://i.stack.imgur.com/ImC0x.png>
>
>
>
> Here is my Redis cluster in my google compute console:
>
> [image: enter image description here] <http://i.stack.imgur.com/kOp0U.png>
>
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
> To post to this group, send email to redi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/redis-db.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages