Cannot subscribe to channel through Realtime: WebSocketChannelException: WebSocket connection failed
- 1
- Flutter
- Realtime

Hello, I am trying to subscribe to a channel using Realtime in my flutter app. I have the following code:
var sub = realtime.subscribe(
["databases.main.collections.teachers.documents"]);
And then have a function which simply calls sub.stream.listen
to listen. When I launch the app, I only get the WebSocketChannelException and in the devtools console of my browser I get can’t establish a connection to the server...
and that the websocket returned an error 400. I tried to look into the appwrite-realtime container logs and it simply listed Connection close: N
over and over. I am pretty sure the realtime endpoint is correct and the collection has its collections permission currently set to allow anyone to read. But I still cannot figure out where is the problem.

Is this self-hosted?

yes

@hernik Are you using any proxy like Nginx, Plesk, Cloudflare....?

Currently my Appwrite is connected Appwrite -> Nginx -> Cloudflare

Maybe that's the issue. Did you have setup traefik to trust both proxys?

I think cloudflare should be ok, but I have no idea how to check if traefik trusts both proxies, do you happen to have some docs on how to check/set that please?


Added, restarted and still the same problem :(

Did you enable websockets in nginx?
Recommended threads
- Getting Error On self host SSL update
Hi, I am using app write for my app backend version i am using is 1.6.2 yesterday my ssl is expired and now i am not able to renew it because of it my app is no...
- Cannot load nested relationships
When trying to load a nested relationship using the below query I get this error: ```Invalid query: Attribute not found in schema: *``` ```dart try { fina...
- Realtime didn't work in react native exp...
``` useEffect(() => { const { client } = createClient(); const unsubscribe = client.subscribe(`databases.${process.env.EXPO_PUBLIC_APPWRITE_DATABASE}.t...
