swampdragon-notifications
swampdragon-notifications copied to clipboard
SWAMP_DRAGON_HEARTBEAT_ENABLED breaks onlineCount
- Enable SWAMP_DRAGON_HEARTBEAT_ENABLED and set SWAMP_DRAGON_HEARTBEAT_FREQUENCY
- Open two connections (two users connecting to websockets)
- Close one connection (close that user's tab)
- Run
notifications.onlineCount(function (count) {
console.log(count);
});
We expect this to be 1. But it is 2. Run the same test with HEARTBEAT disabled and we do get 1.
I was trying to debug by inspecting the user_manager. I did some print statements on add_user and saw the result increments on each HEARTBEAT. Perhaps related? Sorry I don't really know how the user_manager is supposed to be working.
That's interesting, the heartbeat needs to be enabled for the online count to correct it self in case of a skew.
Have you tried this using different browsers rather than tabs? You can't really be signed in as two different users in the same browser (it will overwrite the bookie the next time you sign in)
I think I have it figured out. Let me know if you have questions about my fix. In the process I got to learn about using redis for more than just cache and message queues :)
Redis is amazing! So much more than just a KV store. I'm currently traveling but once I'm back I will review the code and merge it