gosquared / redis-clustr

Redis Cluster client for Node.js
MIT License
107 stars 25 forks source link

pub.send_command is not a function #42

Open 0xAnakin opened 4 years ago

0xAnakin commented 4 years ago

Hello,

I'm using redis-clustr to initialize a clustr connection providing only a server list (host, port).

Packages

Code


pub = sub = new RedisCluster({
    ...settings.redis
});

this.ws.adapter(adapter({
    key: 'quintessa.io',
    pubClient: pub,
    subClient: sub,
    requestsTimeout: 5000
}));

Redis

My setup is 3 masters with the with the following conf files:

port 6379
cluster-enabled yes
cluster-config-file nodes-6379.conf
cluster-node-timeout 5000
appendonly yes
dbfilename dump-6379.rdb

port 6380
cluster-enabled yes
cluster-config-file nodes-6380.conf
cluster-node-timeout 5000
appendonly yes
dbfilename dump-6380.rdb

port 6381
cluster-enabled yes
cluster-config-file nodes-6381.conf
cluster-node-timeout 5000
appendonly yes
dbfilename dump-6381.rdb

Error

The error does not occur when using a just 2 single connections to one of 3 masters or there is no redis setup at all, jsut a single server...

0|index  | TypeError: pub.send_command is not a function
0|index  |     at Redis.clients (D:\Development\GIT\Quintessa\Quintessa\node_modules\socket.io-redis\index.js:438:9)
0|index  |     at D:\Development\GIT\Quintessa\Quintessa\src\back-end\io\admin-sockets-namespace\events\signout\index.js:15:26
0|index  |     at Socket.<anonymous> (D:\Development\GIT\Quintessa\Quintessa\src\back-end\io\index.js:93:17)
0|index  |     at Socket.emit (events.js:311:20)
0|index  |     at Socket.EventEmitter.emit (domain.js:482:12)
0|index  |     at D:\Development\GIT\Quintessa\Quintessa\node_modules\socket.io\lib\socket.js:528:12
0|index  |     at processTicksAndRejections (internal/process/task_queues.js:79:11)
0|index  |  8256 Tue, 26 May 2020 17:39:46 GMT [MetalDust]: TypeError: pub.send_command is not a function
0|index  |     at Redis.clients (D:\Development\GIT\Quintessa\Quintessa\node_modules\socket.io-redis\index.js:438:9)
0|index  |     at D:\Development\GIT\Quintessa\Quintessa\src\back-end\io\admin-sockets-namespace\events\signout\index.js:15:26
0|index  |     at Socket.<anonymous> (D:\Development\GIT\Quintessa\Quintessa\src\back-end\io\index.js:93:17)
0|index  |     at Socket.emit (events.js:311:20)
0|index  |     at Socket.EventEmitter.emit (domain.js:482:12)
0|index  |     at D:\Development\GIT\Quintessa\Quintessa\node_modules\socket.io\lib\socket.js:528:12
0|index  |     at processTicksAndRejections (internal/process/task_queues.js:79:11)

I tried to investigate with the following code, I hope it helps. It seems like pub/sub between servers doesnt work ?

    pub.send_command = function (...args) {

        const connection = pub.getRandomConnection();
        console.log(...args);
        return connection.send_command.call(connection, ...args);

    };

Output:

0|index  | 17276 Tue, 26 May 2020 17:49:56 GMT [MetalDust]: quintessa.io-request#/admin# {"requestid":"leYPpU","type":0,"rooms":["ezeYMpR-gerpW2ekpWh-sCwKrZMS8tr6"]}

And new error after push.send_command:

0|index  | 17276 Tue, 26 May 2020 17:50:01 GMT [MetalDust]: Error: timeout reached while waiting for clients response
0|index  |     at Timeout._onTimeout (D:\Development\GIT\Quintessa\Quintessa\node_modules\socket.io-redis\index.js:457:48)
0|index  |     at listOnTimeout (internal/timers.js:549:17)
0|index  |     at processTimers (internal/timers.js:492:7)