swampdragon-notifications icon indicating copy to clipboard operation
swampdragon-notifications copied to clipboard

SWAMP_DRAGON_HEARTBEAT_ENABLED breaks onlineCount

Open bufke opened this issue 9 years ago • 3 comments

  1. Enable SWAMP_DRAGON_HEARTBEAT_ENABLED and set SWAMP_DRAGON_HEARTBEAT_FREQUENCY
  2. Open two connections (two users connecting to websockets)
  3. Close one connection (close that user's tab)
  4. 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.

bufke avatar May 14 '15 00:05 bufke

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)

hagsteel avatar May 14 '15 08:05 hagsteel

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 :)

bufke avatar May 17 '15 16:05 bufke

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

hagsteel avatar May 19 '15 16:05 hagsteel