
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
- Automatically Assigning the user and tea...
Hey AppWriters! Day 2 for me 😅 I'm reading the docs https://appwrite.io/docs/products/auth/team-invites In order to understand how a document is added then ...
- Realtime Memory Usage
Appwrite-Realtime container has been acting strangely lately. None of my functions use this feature, but it has been consuming a large chunk of memory. When I s...
- How to detect user disconnection?
I'm creating a 1v1 challenge using realtime and i want to trigger a function when the user disconnect... how to make this using Appwrite Realtime? i searched i...
