You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use callbacks and I follow this pattern client-1 -> server -> client-2 -> callback-to-server -> callback-to-client-1 the adapter appears to send messages twice to client-2. Here is replication code. When I comment out all redis things it will only send once
When I use callbacks and I follow this pattern
client-1 -> server -> client-2 -> callback-to-server -> callback-to-client-1
the adapter appears to send messages twice to client-2. Here is replication code. When I comment out all redis things it will only send onceServer
`const socketIo = require("socket.io");
const redisAdapter = require("@socket.io/redis-adapter");
const redis = require("redis");
const io = new socketIo.Server(
{
cors: {
origin: process.env.ORIGIN,
methods: ["GET", "POST"],
credentials: true,
},
}
);
let ns = io.of('/');
const pubClient = redis.createClient({ url: "redisurl" });
const subClient = pubClient.duplicate();
Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
io.adapter(redisAdapter.createAdapter(pubClient, subClient));
io.listen(PORT);
});
pubClient.on('connect', () => {
console.log('::> Redis Client Connected');
});
pubClient.on('error', (err) => {
console.log('<:: Redis Client Error', err);
});
ns.on("connection", async (socket) => {
socket.on("host:broadcast", async (data, callback) => {
const room = socket.to(data.room);
room.emit("member:message", data, (arg) => {
callback(arg);
});
});
});
`
The text was updated successfully, but these errors were encountered: