Skip to content

Sometimes user presence stuck in online status if browser is refreshed multiple times very fast #11293

@distlibs

Description

@distlibs

Description:

I noticed that sometimes user presence stuck in online status if browser is refreshed multiple times very fast. If Rocket Server is restarted, user back to offline after some time.

In ~/Rocket.Chat/packages/rocketchat-livechat/server/unclosedLivechats.js file
I added UserPresence.activeLogs(); myself for user presence testing:

UserPresenceMonitor.onSetUserStatus((user, status/*, statusConnection*/) => {
    UserPresence.activeLogs();

	if (!monitorAgents) {
		return;
	}
	if (onlineAgents.exists(user._id)) {
		if (status === 'offline' || user.statusLivechat === 'not-available') {
			onlineAgents.remove(user._id, () => {
				runAgentLeaveAction(user._id);
			});
		}
	}
});

If browser is refreshed multiple times very fast sometimes two or more connections for same user are created. When browser is closed one connection is removed, but others still exist.
user-presence

I think it's related to konecty:user-presence package. (@sampaiodiego )

Server Setup Information:

  • Version of Rocket.Chat Server: 0.66.0-develop (c413029)
  • Operating System: Ubuntu 18.04
  • Deployment Method: git pull
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: 8.11.3 - x64
  • MongoDB Version: 3.4.10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions