-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Hi! It seems there is an issue with the spublish()/ssubscribe() methods added in 6285e80:
import { Cluster } from "ioredis";
const clusterNodes = [
{
host: "localhost",
port: 7000,
},
{
host: "localhost",
port: 7001,
},
{
host: "localhost",
port: 7002,
},
{
host: "localhost",
port: 7003,
},
{
host: "localhost",
port: 7004,
},
{
host: "localhost",
port: 7005,
},
];
const pubClient = new Cluster(clusterNodes);
const subClient = pubClient.duplicate();
subClient.ssubscribe("foo", () => {
pubClient.spublish("foo", "bar");
});
subClient.on("smessage", (_, message) => {
console.log("got", message); // never received
});The smessage event is not received. It works with classic publish()/subscribe() though:
subClient.subscribe("foo", () => {
pubClient.publish("foo", "bar");
});
subClient.on("message", (_, message) => {
console.log("got", message); // prints "got bar"
});My docker-compose.yml, for reproducibility:
services:
redis-cluster:
image: grokzen/redis-cluster:7.0.10
ports:
- "7000-7005:7000-7005"The test case here looks a bit weird, shouldn't it be something like:
const pub = new Cluster(options);
const ssub = new Cluster(options);
ssub.ssubscribe("test cluster", function () {
pub.spublish("test shard channel", "hi");
// node1.write(node1.findClientByName("ioredis-cluster(subscriber)"), [
// "smessage",
// "test shard channel",
// "hi",
// ]);
});Thanks in advance!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels