Replies: 1 comment
-
Hi! You can listen to the io.on("connection", (socket) => {
socket.conn.on("heartbeat", () => {
// called after each round trip of the heartbeat mechanism
console.log("heartbeat");
});
}); That being said, I think relying on the io.on("connection", (socket) => {
// persist status into Redis
socket.on("disconnect", () => {
// persist status into Redis
});
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a system with over ten thousand devices connected via socket.io. I would like to monitor the heartbeat of these devices using socket.io's built-in heartbeat mechanism and update a timestamp for each device in Redis whenever a heartbeat is detected. This way, I can easily track which devices are currently active and know the total number of active devices.
Since my application is running on multiple Node.js cluster instances, how can I effectively monitor the heartbeats across all these instances and ensure that the heartbeat updates are consistently written to Redis? Specifically, how can I implement a callback to update Redis whenever a heartbeat is detected?
Beta Was this translation helpful? Give feedback.
All reactions