RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.4k stars 10.51k forks source link

UserPresence not working correctly #27790

Open andys448 opened 1 year ago

andys448 commented 1 year ago

Description:

Hi All! When installing HA without Docker, when > 1 instance is used, then in all services it was possible to specify:

DISABLE_PRESENCE_MONITOR=true and do not use this parameter in one service, then the statuses were read and changed correctly according to the AutoAway settings and there were no performance problems.

When using Docker containers - this no longer works, the statuses do not change if the user was online (it does not matter if he left, closed the application (electron), etc) - the status does not change. The user always remains Online, while sometimes away is activated (very rarely), but does not change back to Online (expected behavior)

my docker-compose.yml

version: '3.5'

services:
  rocketchat:
    # Image tag (replace if needed)
    image: 
    deploy:
        replicas: 2
    command: /bin/bash -c 'INSTANCE_IP=$$(hostname -i) node main.js'
    restart: always
    volumes:
      - 
    networks:
      - rc.network
    environment:
     - PORT=3000
      # Rocket.Chat ENV (replace if needed)
     - ROOT_URL
     - MONGO_URL
     - MONGO_OPLOG_URL
     - NOTIFICATIONS_SCHEDULE_DELAY_ONLINE
     - NOTIFICATIONS_SCHEDULE_DELAY_AWAY
     - DISABLE_PRESENCE_MONITOR=yes
     - USE_NATIVE_OPLOG
     - INSTANCE_IP
     - NODE_EXTRA_CA_CERTS
    ports:
        - "3000-3001:3000"
  rocketchat-2:
    # Image tag (replace if needed)
    image: 
    command: /bin/bash -c 'INSTANCE_IP=$$(hostname -i) node main.js'
    restart: always
    volumes:
      - 
    networks:
      - rc.network
    environment:
     - PORT=3000
      # Rocket.Chat ENV (replace if needed)
     - ROOT_URL
     - MONGO_URL
     - MONGO_OPLOG_URL
     - NOTIFICATIONS_SCHEDULE_DELAY_ONLINE
     - NOTIFICATIONS_SCHEDULE_DELAY_AWAY
     - USE_NATIVE_OPLOG
     - INSTANCE_IP
     - NODE_EXTRA_CA_CERTS
    ports:
        - "3002:3000"
networks:
    rc.network:

.env

MONGO_URL=mongodb://user:pass@db01:27017,db02:27017/rocketchat?authSource=admin&replicaSet=rs01
MONGO_OPLOG_URL=mongodb://user:pass@db01:27017,db02:27017/local?authSource=admin&replicaSet=rs01
ROOT_URL=https://-
NOTIFICATIONS_SCHEDULE_DELAY_ONLINE=10
NOTIFICATIONS_SCHEDULE_DELAY_AWAY=5
USE_NATIVE_OPLOG=true
NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/ca-bundle.crt

https://forums.rocket.chat/t/shows-all-as-online/15619/6

db.usersSessions.deleteMany({}) db.users.updateMany({status:"online"},{$set:{status:"offline"}})

Resetting sessions, as indicated by the link above, does not help, the user becomes Online again. Yes, his application is running, but the computer is locked and no one is working on it. In the RocketChat logs I see:

Meteor ➔ method 10.230.115.24 - r3tspJQCSgZYR3zcv [2023-01-15T23:37:07.203Z] "METHOD UserPresence:away" - "undefined" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Rocket.Chat/3.8.9 Chrome/98.0.4758.141 Electron/17.4.11 Safari/537.36"

But for these users, the status does not change, it is still displayed as Online, in the mongo UserSessions table - Online is also displayed.

I also tried to restore the production mongo db on the test RC, and for the past 3 weeks, 35 users have had the Online status, but no one has access to this test server :smiley: .

In the logs of the Docker container, I periodically observe the following:

Meteor ➔ method null - null [2023-01-15T00:19:19.971Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:20.047Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:20.188Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:20.296Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:20.366Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:20.461Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:20.545Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:20.626Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:20.759Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:20.898Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:21.007Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:21.091Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:21.230Z] "METHOD stream:local" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:21.350Z] "METHOD stream:notify-room" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:21.502Z] "METHOD stream:notify-user" - "undefined" "undefined" |
Meteor ➔ method null - null [2023-01-15T00:19:21.503Z] "METHOD stream:notify-user" - "undefined" "undefined" |

This problem is observed only in Docker, everything works correctly in a stand-alone installation without using containers.

This bug reproduces on 3., 4., 5.* versions and Docker only.

Nginx config from rocket docs with upstreams.

Thanks for any help!

Steps to reproduce:

  1. Install RocketChat in Docker / multiple-instances
  2. Install Electron App
  3. Enable AutoAway
  4. Login via Electron App
  5. Lock Screen
  6. User is still online (always)

Expected behavior:

Must be idle time-out and userpresence changed to away

Actual behavior:

Server Setup Information:

Client Setup Information

Additional context

Relevant logs:

matthias4217 commented 1 year ago

This looks like a duplicate of #27145. Unfortunately, nothing seems to have been done on the matter.

bseclier commented 1 year ago

The issue is still in 5.4.10 and the UsersSessions cleanup didn't solve the problem.