
Hey guys, i am using this code to access my database using realtime
client.subscribe('databases.[ID].collections.[ID].documents.create', (payload: any) => {
console.log(payload)
})
I have replaced the [ID] for the corresponding ID i dont know what is the problem.
this is the errors i am getting
WebSocket connection to 'wss:///v1/realtime?project=ID&channels%5B%5D=collections.6406910f7d0377e9d2.documents.create&channels%5B%5D=collections.642607b69f346b1aac6d.documents.create&channels%5B%5D=databases.642607ad8b10bc1f0b79.collections.642607b69f346b1aac6d.documents.create' failed:
createSocket @ client.ts:235
(anonymous) @ client.ts:257
client.ts:253 Realtime got disconnected. Reconnect will be attempted in 10 seconds.

Have you initialized the client with the endpoint?

const client = new Client()
.setEndpoint('https://[HOSTNAME_OR_IP]/v1')
.setProject('[PROJECT_ID]');

yes, it is initialized

Run
docker ps
Do you see that realtime is indeed running?

yes, it is running, maybe i should change the running port because i have changed it to traefik?

nope not worked

i can fetch data from the database but i cant subscribe

When you have changed the main docker port, do you also changed the realtime?
appwrite-realtime:
image: appwrite/appwrite:1.2.1
entrypoint: realtime
container_name: appwrite-realtime
<<: *x-logging
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.constraint-label-stack=appwrite"
- "traefik.docker.network=appwrite"
- "traefik.http.services.appwrite_realtime.loadbalancer.server.port=80"
#ws
- traefik.http.routers.appwrite_realtime_ws.entrypoints=appwrite_web
- traefik.http.routers.appwrite_realtime_ws.rule=PathPrefix(`/v1/realtime`)
- traefik.http.routers.appwrite_realtime_ws.service=appwrite_realtime
# wss
- traefik.http.routers.appwrite_realtime_wss.entrypoints=appwrite_websecure
- traefik.http.routers.appwrite_realtime_wss.rule=PathPrefix(`/v1/realtime`)
- traefik.http.routers.appwrite_realtime_wss.service=appwrite_realtime
- traefik.http.routers.appwrite_realtime_wss.tls=true
- traefik.http.routers.appwrite_realtime_wss.tls.certresolver=dns

i have tried changing it but it didnt work

Do you have a reverse proxy in front of Appwrite?

yes i have, i am using nginx

is nginx configured for web sockets?

it is fixed now, i have added this lines to nginx, thank you for your help ```
WebSocket configuration
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;```

[SOLVED]Realtime getting disconnected and websocket connection failed

8
Recommended threads
- Realtime didn't work in react native exp...
``` useEffect(() => { const { client } = createClient(); const unsubscribe = client.subscribe(`databases.${process.env.EXPO_PUBLIC_APPWRITE_DATABASE}.t...
- Finally installed AppWrite through Cooli...
Finally installed AppWrite through Coolify, can log in and use Functions normally, but Realtime reports an error AppWrite container logs: 2025-09-05T14:54:26....
- Realtime listener does not get update wh...
listener (flutter) ``` realtime .subscribe(['databases.6882943XXXXX.tables.public.rows.main']) .stream .listen((message) { print(message); });``` ...
