Rocket.chat desktop app shows 404 after inactivity

Description

I have recently installed rocket.chat as a docker instance running behind a traefik reverse proxy.

Everything works well, but after i leave the desktop app running in the background and i’m not interacting with it for a bit and i go back to send a message, it does not send, and everything stops loading.

With the same criteria, sometimes it also shows “You’re offline, trying to reconnect in xxx seconds”, no matter how much i press connect it does not go away.

Pressing “reload” or “force reload” either shows 404 not found, or it completely redirects me to the non proxied site of my domain. I have to kill the app with task manager and reopen it for it to reconnect.

Rocketchat shows no error logs while this happens, neither does the database.

Any advice?

Server Setup Information

  • Version of Rocket.Chat Server: 7.1.0
  • Operating System: Windows 11 24H2
  • Deployment Method: Docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • NodeJS Version:
  • MongoDB Version: 6.0
  • Proxy: Traefik
  • Firewalls involved: No

Any additional Information

docker compose file:

volumes:
  mongodb_data: { driver: local }

services:
  rocketchat:
    image: ${IMAGE:-registry.rocket.chat/rocketchat/rocket.chat}:${RELEASE:-latest}
    container_name: rocketchat
    restart: unless-stopped
    labels:
      traefik.enable: "true"
      traefik.http.routers.rocketchat.rule: Host(`${DOMAIN:-}`)
      traefik.http.routers.rocketchat.tls: "true"
      traefik.http.routers.rocketchat.entrypoints: https
      traefik.http.services.rocketchat.loadbalancer.server.port: 3000
    environment:
      MONGO_URL: "${MONGO_URL:-\
        mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
        ${MONGODB_DATABASE:-rocketchat}?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
      MONGO_OPLOG_URL: "${MONGO_OPLOG_URL:\
        -mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
        local?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
      ROOT_URL: ${ROOT_URL:-http://localhost:${HOST_PORT:-3000}}
      PORT: ${PORT:-3000}
      DEPLOY_METHOD: docker
      DEPLOY_PLATFORM: ${DEPLOY_PLATFORM:-}
      REG_TOKEN: ${REG_TOKEN:-}
    depends_on:
      - mongodb
    expose:
      - ${PORT:-3000}
    networks:
      - proxy


  mongodb:
    image: docker.io/bitnami/mongodb:${MONGODB_VERSION:-6.0}
    container_name: rocketchat-mongodb
    restart: unless-stopped
    volumes:
      - mongodb_data:/bitnami/mongodb
    environment:
      MONGODB_REPLICA_SET_MODE: primary
      MONGODB_REPLICA_SET_NAME: ${MONGODB_REPLICA_SET_NAME:-rs0}
      MONGODB_PORT_NUMBER: ${MONGODB_PORT_NUMBER:-27017}
      MONGODB_INITIAL_PRIMARY_HOST: ${MONGODB_INITIAL_PRIMARY_HOST:-mongodb}
      MONGODB_INITIAL_PRIMARY_PORT_NUMBER: ${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}
      MONGODB_ADVERTISED_HOSTNAME: ${MONGODB_ADVERTISED_HOSTNAME:-mongodb}
      MONGODB_ENABLE_JOURNAL: ${MONGODB_ENABLE_JOURNAL:-true}
      ALLOW_EMPTY_PASSWORD: ${ALLOW_EMPTY_PASSWORD:-yes}
    networks:
      - proxy

networks:
  proxy:
    external: true

devtools console log during issue:

Not sure how relevant this is to the issue, traefik shows a couple of these every once in a while:

2025-01-02T07:38:23+01:00 DBG github.com/traefik/traefik/v3/pkg/proxy/httputil/proxy.go:113 > 499 Client Closed Request error="context canceled"

2025-01-02T07:38:23+01:00 DBG github.com/traefik/traefik/v3/pkg/proxy/httputil/proxy.go:113 > 499 Client Closed Request error="context canceled"

Your compose file is not much use with the .env component.

Check your websocketsb- and test with a browser to eliminate the client:

Once set with the correct domain, don’t login with the local ip:3000 as it may set the server name back to localhost which will confuse everything.

You can adjust the log level in rocket.

Also read how to use docker logging.

Regrettably I know nothing much about Windows as I haven’t touched it in 15+ years so can’t help with that - it’s not a great platform for this.

First off, I have misunderstood some of the information i was meant to provide, so here’s a correction:

Server Setup Information

  • Version of Rocket.Chat Server: 7.1.0
  • Operating System: Ubuntu 24.04 Server running inside Proxmox
  • Deployment Method: Docker
  • Number of Running Instances: 1
  • NodeJS Version: 20.18.0
  • MongoDB Version: 6.0.13
  • Proxy: Traefik
  • Firewalls Involved: No

I tested the websockets on a browser, they return 101 and after leaving the page sit there for a while and then coming back, everything still worked fine whileas on the desktop client it already told me “You’re offline”.

While being away from home the mobile app also shows similar symptoms. First time upon opening it, it connects. But after i come back to it for a third or fourth time, it just says “Waiting for connection”, tries to connect and then waits again.

Desktop app runs in a Windows 11 environment, version 4.1.2
Mobile app runs on a phone with Android 15, latest version from Google Play Store

I set the rocketchat log level to debug to check for any issues but all of the logs show these kinds of logs with status codes of nothing else but 200:

{"level":35,"time":"2025-01-03T08:23:00.774Z","pid":1,"hostname":"b8465b2c5aa4","name":"API","method":"POST","url":"/api/v1/method.call/rooms%3Aget","userId":"xxxxxxxxx","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0","length":"111","host":"rocketchat.xxxxxx.eu","referer":"https://rocketchat.xxxxxx.eu/home","remoteIP":"192.168.51.15","status":200,"responseTime":3} 

I have always used the proxied domain to access rocketchat, and in the docker compose I do not have port 3000 exposed so I am not even able to access it via local IP.

here are the .env variables:

RELASE=latest
DOMAIN=rocketchat.xxxxxx.eu
PORT=3000
ROOT_URL=https://rocketchat.xxxxxx.eu
BIND_IP=192.168.110.10 # originally I had this set as 127.0.0.1 and I tried setting it to the docker ip to check if that fixed anything

Hmmm.

I can pretty well guarantee this is your network setup, but pinning down what it is will be tricky.

Two things give a clue:

So 192.168.110.x

And 192.168.51.x

I’d take a look at your prox network and any firewalls.

Note if you are using docker with traefik 127.0.0.1 should work.

You can also shell into the rocket container & check networking from there as well.

After pinging all devices that have rocketchat from the container, i have noticed a pattern.

Pinging my own windows machine and another one gives me no reply.
Pinging a linux machine does give me a reply.

Said linux machine does not have these kinds of issues. Is it possible that the firewall on windows is blocking certain requests that rocketchat needs?

I wouldn’t be surprised…

Disable the firewall and test.

Also test browser vs client.

I tried disabling the firewall for rocketchat, nothing changed.

Opened the app and a browser instance at the same time, it’s been five minutes and the app devtools already show a status of 404 and nothing works. Browser works fine. What i’ve noticed in the app though is, the first thing that fails in the network tab is some externalComponents path.

Update:

Upon further inspection of my DNS settings everywhere, i have noticed a 1.1.1.1 server in my router settings which i suspect may have been the culprit.

After locally setting my DNS servers to the ones that actually route my proxy, the network devtools tab shows double the requests, including a websocket that prior to this only showed in the browser.

My VPN that i use for a mobile tunnel also had cloudflare DNS servers set.

I will correct this, test a little and if i don’t encounter the issue again, i will close this as solved.

Excellent.

From experience networking/DNS is usually the culprit in this type of scenario. It’s just a case of nailing it down!

Keep us posted.

I’m happy to say that on desktop, the issue was fixed!

However, the other issue persists on mobile (Upon opening the app, it runs in an infinite loop of connecting and waiting for connection and rarely actually connects)

On home Wifi, i am unable to replicate the issue.
But on mobile data it almost always forever tries to connect and only 5% of the time actually connects successfully (on full bars). So it is probably a network issue.

I have another app that runs on the same reverse proxy (immich) and i’ve never had such a connection issue there. On mobile data, it connects flawlessly so i don’t think it would be incorrect VPN configuration, could be a DNS issue though.

Are there tools to debug these kinds of issues on mobile?

This will be network/dns/websockets again for sure. I think you still have issues to resolve.

You sure you have https & certs setup correctly?

Easiest is to try a laptop remotely.

Looks like it was probably something to do with caching. Reinstalled the app and I haven’t had that issue since.

Thank you for your help!

Fab!

It helps to dump the cache between version upgrades.

Gets itself in a mucking fuddle quite often!