#Realtime connection error: WebSocketException: ... was not upgraded to websocket

49 messages · Page 1 of 1 (latest)

feral gorge
#

My application has lots of chat rooms created daily, and a common error is that the realtime connection is not working, the console shows this error:

flutter: WebSocketException: Connection to 'https://cloud.appwrite.io:0/v1/realtime?project=prject_id&channels%5B%5D=databases.chat.collections.dn1m1gh2kzkdmoe.documents#' was not upgraded to websocket
#0      _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1011:41)
#1      WebSocket.connect (dart:_http/websocket.dart:320:22)
#2      RealtimeIO._getWebSocket (package:appwrite/src/realtime_io.dart:37:27)
#3      RealtimeMixin._createSocket (package:appwrite/src/realtime_mixin.dart:33:17)```

Just after creating some documents in that collection the next attempt of doing a realtime connection works. This error occasionally occurs with some collections.

Using appwrite cloud v.1.4.13
Appwrite for flutter: v11.0.1
loud topaz
warped musk
#

I have been experiencing this lately

feral gorge
# loud topaz Is this during development or in release mode?

I have reports in firebase in release mode. As the functionality is not being widely used, I have few reports, and also I have a video report that I identified to be the same error because the behavior. So it's a problem in flutter and not in the database itself, right? Do you know why this happens on hot reload? Maybe I'm doing something wrong that causes the same error as after hot reload.

loud topaz
# feral gorge I have reports in firebase in release mode. As the functionality is not being wi...

I have reports in firebase in release mode. As the functionality is not being widely used, I have few reports, and also I have a video report that I identified to be the same error because the behavior.

Can you share?

So it's a problem in flutter and not in the database itself, right? Do you know why this happens on hot reload? Maybe I'm doing something wrong that causes the same error as after hot reload.

I always assumed reloading causes weird things to happen to web sockets because web sockets need to keep a long running connection

feral gorge
loud topaz
# feral gorge

thanks for the confirmation. What version of the appwrite flutter sdk are you using?

loud topaz
feral gorge
feral gorge
#

the worst thing, is that there is no way to catch that. I surrounded the subscribe into a try catch, but this error occurs and the catch is not executed neither the onError or onDone methods are called.

burnt gale
#

This happens to me as well. Is there any fix for it?

loud topaz
glass pike
#

I am also experiencing the same issue. Sometimes it works but sometimes it does not. I have also experienced this error in production. The interesting thing is I did not experience this in my self hosted appwrite instance. I will need to double check if my selfhosted instance was the same version is appwrite cloud.

warped musk
feral gorge
#

@glass pike In fact, I have never had this problem using my self host appwrite. But my self host appwrite was in a previous version.

loud topaz
warped musk
feral gorge
#

@warped musk
I have the reference of these two.
Then in my screen dispose method, I cancel them.

#

But the problem happens even in the first time I am subscribing to the collection. When everything is clear

warped musk
feral gorge
glass pike
loud topaz
warped musk
warped musk
loud topaz
warped musk
#

By doing that my application run smoothly whole the time

#

the error will not show anymore

feral gorge
# warped musk I want to share about this in regards on my experience. Actually the error occur...

Ok, I have more info about this.
Until now, all the reports are from iOS, no Androids were affected. I have few users using this function, so it can maybe occurs in android too.

The spot where I work hasn't a good wifi signal, so as you commented about the wifi I've tested using 5g, and after several attempts I was not able to reproduce the error, only with wifi. But it's pretty easy to happen when I am using wifi, even if all other applications are working correctly.

#

So, it looks like connectivity problem. So the problem is that the sdk doesn't dispatch any error when the connection goes bad in that time

feral gorge
#

I have reported this in a github thread some months ago. I also presented two alternatives to let us catch connectivity problems, but it was not implemented. Both solutions would bring break change.

warped musk
#

I think that if there are errors occur on websocket I think it should redirect on the onErrorListener

feral gorge
#

I agree

warped musk
#

but the problem is that I cant even catch the error

feral gorge
#

I have implemented a reconnection protocol, but as the sdk doesn't report error I can't never execute it when some connection issue happens.

warped musk
#

So we can conclude that this error is related to internet connectivity? And we have to implement on how to handle the internet issue related?

feral gorge
#

more than 1 year ago, @loud topaz I think we should take a look into this.

feral gorge
loud topaz
loud topaz
glass pike
#

Also is there any workaround currently for this?

loud topaz
warped musk
edgy brook
#

cc: @mellow yew @loud topaz