Skip to content

Commit 10b48be

Browse files
authored
Merge pull request #1 from winchell/socket.io-redis-issue-494
Detect node-redis RedisCluster client and use corresponding sendComma…
2 parents b5da02d + 28453e2 commit 10b48be

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ export class RedisAdapter extends Adapter {
900900
this.pubClient.constructor.name === "Cluster" ||
901901
this.pubClient.isCluster
902902
) {
903-
// Cluster
903+
// ioreids Cluster
904904
const nodes = this.pubClient.nodes();
905905
return Promise.all(
906906
nodes.map((node) =>
@@ -913,12 +913,19 @@ export class RedisAdapter extends Adapter {
913913
});
914914
return numSub;
915915
});
916+
// node-redis
916917
} else if (typeof this.pubClient.pSubscribe === "function") {
917-
return this.pubClient
918+
if(Object.getPrototypeOf(Object.getPrototypeOf(this.pubClient)).constructor.name === 'RedisCluster') {
919+
return this.pubClient
920+
.sendCommand(undefined, true, ["pubsub", "numsub", this.requestChannel])
921+
.then((res) => parseInt(res[1], 10));
922+
} else {
923+
return this.pubClient
918924
.sendCommand(["pubsub", "numsub", this.requestChannel])
919925
.then((res) => parseInt(res[1], 10));
926+
}
920927
} else {
921-
// RedisClient or Redis
928+
// ioredis RedisClient or Redis
922929
return new Promise((resolve, reject) => {
923930
this.pubClient.send_command(
924931
"pubsub",

0 commit comments

Comments
 (0)