Users do not go Offline and always stay Online
Problem: Since our update to 5.x (currently running 5.4.0) some users are always shown as Online even though they are not connected on any device. This results in no offline notification emails sent and confused users.
Details / attempts without success: Using the "Logout from other devices" function within the users profile does not change anything. Manually logging out from all clients (desktop, mobile) does not change anything. Deactivating / Locking the user as an Administrator does not change anything.
In all of those cases the user stays Online (which results in no offline email notifications beeing sent):

Manually changing the status to Offline helps and changes the status, but would then stay Offline even if the user is online. Manually switching it back to Online changes the status, but now we are stuck again with beeing always Online (as before).
When Updating to 5.4.0 the affected users were automatically & directly online once RocketChat came online.
Old Bugreport with the identical issue: https://github.com/RocketChat/Rocket.Chat/issues/16455 (from 2020) https://github.com/RocketChat/Rocket.Chat/issues/27145 (October2022 to still open) https://github.com/RocketChat/Rocket.Chat/issues/27465 (opened today)
Logfiles: The server receives the Logout and it works as designed for most of the users:
{"level":35,"time":"2022-12-06T16:19:09.068Z","pid":8,"hostname":"REDACTED","name":"Meteor","method":"logoutCleanUp","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36","referer":"https://REDACTED/home","remoteIP":"REDACTED","instanceId":"REDACTED"}
{"level":35,"time":"2022-12-06T16:19:09.069Z","pid":8,"hostname":"REDACTED","name":"API","method":"POST","url":"/api/v1/method.callAnon/logoutCleanUp","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36","length":"27333","host":"REDACTED","referer":"https://REDACTED/home","remoteIP":"REDACTED","status":200,"responseTime":2}
Environment: Since the problem only affects a few instead of all users and only started recently, i do not believe that it is infrastructure related.
Running 2 Docker containers & natively running NGINX Reverse Proxy infront of it:

Client: Docker Engine - Community Version: 20.10.21 API version: 1.41 Go version: go1.18.7 Git commit: baeda1f Built: Tue Oct 25 18:02:00 2022 OS/Arch: linux/amd64 Context: default Experimental: true
Server: Docker Engine - Community Engine: Version: 20.10.21 API version: 1.41 (minimum version 1.12) Go version: go1.18.7 Git commit: 3056208 Built: Tue Oct 25 17:59:53 2022 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.10 GitCommit: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0
Rocket.Chat: Version der Anwendungs-Engine 1.36.0 Node-Version v14.19.3 Datenbankmigration 281 (6. Dezember 2022 17:25) MongoDB 5.0.8 / wiredTiger (oplog Aktiviert)
I can run additional tests or submit further logfiles if you want to test something.
Using https://github.com/RocketChat/Rocket.Chat/issues/27145 as a reference i tried my luck with resetting the sessions:
- docker exec -it MongoDBDockerContainerNameHere mongo (since we are running Mongo in a Docker container)
- use rocketchat
- db.usersSessions.deleteMany({})
- db.users.updateMany({status:"online"},{$set:{status:"offline"}})
- exit
Now all users are Offline (even those that are Online and incl. rocket.cat which is now shown as offline too), but this fixes itself after a user closes/starts their Browser/App. Everything fine now!
Defenitely stuck entries in session table. Maybe add a cleanup into the "Logout from other/all devices function"?
same problem after update to 5.4
same here since update from 4.8.* to 5.3.*
RocketChat 5.3.4
Mongo: 4.4.18 (oplog Enabled)
Node v14.21.1
db.usersSessions.deleteMany({})
This apparently helped with a few users, but not all.
Reproduced with 5.3.5
same problem since update to 5.4.1
Ich habe das Problem auch mit der Version 5.4.0. Der Admin ist dauerhaft online
Being able to see who is Online and Offline is a basic feature of any chat application. And still, this issue has been opened for two months, and nobody from RocketChat seems to have any interest.
I'm pretty sure there is a lot more impacted users than that this issue shows.
Yes i agree , problem still persistent even on 5.4.2
Me to, many users are persistent online...
The problem persists on version 5.4.3. I hope there is still time to fix this on version 6.0+?
seems no one really is on about this would any of the devs mind pushing this ? @sampaiodiego maybe
@ggazzo help
i have somewhat similar issue, push notifications are working for mobile app but desktop and browser are not, tried cleaning up sessions from mongodb and still no luck with desktop and browser, my main installation is 5.4.0 tried also with 6.0-rc6, and just for a test 4.5 and it worked on 4.5 rocketchat version.
For us upgrading 5.4.5 from to 6.1.0 fixed the issue.
Hi there, thanks for the contribution! 🚀 💯
Sorry, this error does not happen on the latest releases.
Questions? Help needed? Feature Requests?
- Join our Open Server in the #support channel and feel free to raise a question
- Join our Community Forum and search/create a post there
- Feature Request: Open an issue in Feature Request repository
Can not confirm that its working on 6.1.1, autoaway is set to 60 but status remains the same (online) other users see account as offline
I did have the problem while using the 5.x branch and fixed it by clearing the sessions as mentioned.
I've been on the 6.x branch for a few weeks now and have noticed that the stale session problem occurs again!
The issue is still in 5.4.10 and the UsersSessions cleanup didn't solve the problem.
I just experienced this bug on version 6.6.0. I adopted @CR0815 answer to write a simple script reset-sessions.sh to take care of this until the bug is resolved permanently.
#!/bin/bash
docker exec -it rocketchat-mongo-1 mongo --eval "\
db = db.getSiblingDB('rocketchat'); \
db.usersSessions.deleteMany({}); \
db.users.updateMany({status:'online'},{'\$set':{status:'offline'}});"
Ideas why this bug returned?
@pythys your script is not a workaround for the current issue.. the issue is just showing the correct status in the UI, the state that is stored in the database is correct at this time.