UserPresence not working correctly

Description

Server Setup Information

  • Version of Rocket.Chat Server: 5.4.* or 3.18.*
  • Operating System: RHEL 8
  • Deployment Method: Docker
  • Number of Running Instances: >3
  • DB Replicaset Oplog: -
  • NodeJS Version: 14.x
  • MongoDB Version: 4.4
  • Proxy: nginx
  • Firewalls involved:

Any additional Information

Hi All!
Referring to the issue below:

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-1:
    container_name: rocketchat-1
    # Image tag (replace if needed)
    image: git.company.com:1234/rocketchat/rc_server/rc_docker/rocketchat:latest
    restart: always
    command: /bin/bash -c 'INSTANCE_IP=$$(hostname -i) node main.js'
    volumes:
      - /data/rocket_uploads:/data/rocket_uploads:z
      - /data/certs/:/usr/local/share/ca-certificates/:Z
    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:3000"
    depends_on:
        - rocketchat-2
  rocketchat-2:
    container_name: rocketchat-2
    # Image tag (replace if needed)
    image: git.company.com:1234/rocketchat/rc_server/rc_docker/rocketchat:latest
    restart: always
    command: /bin/bash -c 'INSTANCE_IP=$$(hostname -i) node main.js'
    volumes:
      - /data/rocket_uploads:/data/rocket_uploads:z
      - /data/certs/:/usr/local/share/ca-certificates/:Z
    networks:
      - rc.network
    environment:
     - PORT=3001
      # 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:
        - "3001:3001"
  rocketchat-3:
    container_name: rocketchat-3
    # Image tag (replace if needed)
    image: git.company.com:1234/rocketchat/rc_server/rc_docker/rocketchat:latest
    restart: always
    command: /bin/bash -c 'INSTANCE_IP=$$(hostname -i) node main.js'
    volumes:
      - /data/rocket_uploads:/data/rocket_uploads:z
      - /data/certs/:/usr/local/share/ca-certificates/:Z
    networks:
      - rc.network
    environment:
     - PORT=3002
      # 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:
        - "3002:3002"
    depends_on:
        - rocketchat-2
  rocketchat-4:
    container_name: rocketchat-4
    # Image tag (replace if needed)
    image: git.company.com:1234/rocketchat/rc_server/rc_docker/rocketchat:latest
    restart: always
    command: /bin/bash -c 'INSTANCE_IP=$$(hostname -i) node main.js'
    volumes:
      - /data/rocket_uploads:/data/rocket_uploads:z
      - /data/certs/:/usr/local/share/ca-certificates/:Z
    networks:
      - rc.network
    environment:
     - PORT=3003
      # 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:
        - "3003:3003"
    depends_on:
        - rocketchat-2
  rocketchat-5:
    container_name: rocketchat-5
    # Image tag (replace if needed)
    image: git.company.com:1234/rocketchat/rc_server/rc_docker/rocketchat:latest
    restart: always
    command: /bin/bash -c 'INSTANCE_IP=$$(hostname -i) node main.js'
    volumes:
      - /data/rocket_uploads:/data/rocket_uploads:z
      - /data/certs/:/usr/local/share/ca-certificates/:Z
    networks:
      - rc.network
    environment:
     - PORT=3004
      # 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:
        - "3004:3004"
    depends_on:
        - rocketchat-2
  rocketchat-6:
    container_name: rocketchat-6
    # Image tag (replace if needed)
    image: git.company.com:1234/rocketchat/rc_server/rc_docker/rocketchat:latest
    restart: always
    command: /bin/bash -c 'INSTANCE_IP=$$(hostname -i) node main.js'
    volumes:
      - /data/rocket_uploads:/data/rocket_uploads:z
      - /data/certs/:/usr/local/share/ca-certificates/:Z
    networks:
      - rc.network
    environment:
     - PORT=3005
      # 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:
        - "3005:3005"
    depends_on:
        - rocketchat-2
networks:
    rc.network:

.env

MONGO_URL=mongodb://user:pass@db01:27017,db02:27017/rocketchat?authSource=admin&replicaSet=rs01&w=majority
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

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!

Experiencing the same problem with version 5.4.1 on a standalone install on Ubuntu.