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 with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...
- i am getting 404 not found in my current...
in my current appwrite i am getting 404 not found from backend side and in frontend getting error of CORS error as backend is not working
- How to create a custom authentication sy...
I’m looking to create an Appwrite function that first verifies a client using some custom logic, like providing a secret key. Once this verification is complete...