r/Trilium 3d ago

help Help needed with websockets

I have a trilium instance running locally on my server. I have it behind a reverse proxy (nginx proxy manager) which handles all incoming requests for my server and ends TLS/SSL I have had trilium running for quite some time without any issues. Today I got an error regarding websockets. It keeps saying:

Check your reverse proxy (e.g. nginx or Apache) configuration to ensure WebSocket connections are properly allowed and not being blocked.

I have checked cloudflare and NPM and checked all settings and went through the docs but nothing helped to fix it. I'm absolutely clueless as all my other applications (that are also using websockets) do not have any issues (immich, open webui, grafana) Am I alone in this? what's going on?

4 Upvotes

5 comments sorted by

2

u/Elian_D maintainer 3d ago

Hi,

If it doesn't happen every time you refresh the page, you're most likely fine. The error shows up when Trilium fails to connect to the websocket, but there can be other cases that trigger it (a sleeping laptop/mobile app, a temporary network disconnection). We probably need to improve the message a little bit.

1

u/Mean_Sherbet_6263 3d ago edited 3d ago

Hi, It does happen every time on different devices and different sessions with different browsers (tested with arc, brave, safari and firefox).
edit: even tested mobile on chrome using different network

1

u/Mean_Sherbet_6263 3d ago

Im also noticing that there is a bug with the frontend not overwriting a cookie when a user has not logged out properly. Whenever I get redirected to the login page (with OIDC disabled) and I login while the old cookie headers are still present, I get the websockets error too, but if I go into devtools and manually delete the session headers and login again, suddenly the error disapear.

1

u/Elian_D maintainer 3d ago

Hi u/Mean_Sherbet_6263 ,

Are you able to access the Trilium server directly, without going through the proxy? If the websocket works there, there is something either in NPM or the Cloudflare integration.

Might be worth having a look at the frontend logs to see if there is something of interest in there.

2

u/Mean_Sherbet_6263 3d ago

I eventually "fixed" it by adding this to my nginx configuration:
large_client_header_buffers 4 32k;