Back

Flutter realtime

  • 0
  • Flutter
  • Cloud
alex2341355
26 Mar, 2024, 16:02

realtime simply turns off when the application is not in use. It may turn off in 5 minutes or maybe in an hour. This lasts for months. no changes. there are no errors. it just turns off. Windows and Mac OS platforms. starts working only after restarting the application

TL;DR
Developers are experiencing sporadic issues with Flutter realtime subscriptions, mainly as a result of multiple websocket connections occurring simultaneously. Users have tried various workarounds, such as creating separate Realtime instances for each listener and updating a dummy document periodically to check if the subscription is still active. It has been recommended to avoid having too many active channels at once. Another suggestion involves utilizing the Connectivity plugin to monitor changes in internet connectivity and reactivating the realtime listener accordingly. Additionally, conflicts with Socket.IO usage have been noted. The developers have reported errors like WebSocketException and AppwriteException, often related to project IDs or connection upgrades. The issue persists
alex2341355
26 Mar, 2024, 16:02

both in dev mode and in release

alex2341355
26 Mar, 2024, 16:03

cloud

alex2341355
27 Mar, 2024, 20:02

another error with realtime. I do not understand anything

flutter: subscription: wss://cloud.appwrite.io/v1/realtime?project=bongotakso&channels%5B%5D=databases.bongoDb.collections.work_session.documents [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: AppwriteException: , Missing or unknown project ID (1008) #0 RealtimeMixin.handleError (package:appwrite/src/realtime_mixin.dart:157:7) #1 RealtimeMixin._createSocket.<anonymous closure> (package:appwrite/src/realtime_mixin.dart:50:13) #2 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10) #3 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) #4 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) #5 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11) #6 _HandleErrorStream._handleData (dart:async/stream_pipe.dart:253:10) #7 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13) #8 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10) #9 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) #10 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) <…>

alex2341355
27 Mar, 2024, 20:04

hey appwrite team! what about realtime? it works very poorly

D5
27 Mar, 2024, 22:10

Are you sure that's not related to connection?

alex2341355
28 Mar, 2024, 06:57

yes, I am sure. 500Mbit optical channel

alex2341355
28 Mar, 2024, 07:02

There is no way to check the connection in SDK. for example - realtime.ping() or some

alex2341355
28 Mar, 2024, 07:04

I also use socket io. could there be conflicts?

alex2341355
28 Mar, 2024, 07:20

socket.io connection not disconnect.

alex2341355
28 Mar, 2024, 10:52

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: WebSocketException: Connection to 'https://cloud.appwrite.io:0/v1/realtime?project=bongotakso&amp;channels%5B%5D=databases.bongoDb.collections.work_session.documents.1711619920776#' 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) <asynchronous suspension> #3 RealtimeMixin._createSocket (package:appwrite/src/realtime_mixin.dart:33:17) <asynchronous suspension>

D5
28 Mar, 2024, 10:59

No idea πŸ€”

D5
29 Mar, 2024, 00:03

What's the SDK version you're using?

alex2341355
29 Mar, 2024, 05:20

appwrite: ^11.0.1

alex2341355
29 Mar, 2024, 12:03

I immediately subscribe to three channels. Maybe this is not possible?

ChangeNotifierProvider<DriverProvider>( lazy: false, create: (context) => DriverProvider() ..getDrivers() ..getDriversRealtime(), ), ChangeNotifierProvider<OrderProvider>( lazy: false, create: (context) => OrderProvider() ..getOrdersList() ..getOrdersListRealtime(), ), ChangeNotifierProvider<RideProvider>( lazy: false, create: (context) => RideProvider() ..getActiveDrivers() ..getActiveDriversRealtime(context), ),

outrelouxhe
29 Mar, 2024, 12:07

I have the same issue and to check if realtime is up, I regularly update a dummy document and check if I receive the update event. If not, then I reset the subscription. It's a bit cumbersome but it's the only solution I have found until now.

alex2341355
29 Mar, 2024, 12:29
alex2341355
29 Mar, 2024, 12:31

I need to create a new realtime instance for each listener?

alex2341355
29 Mar, 2024, 12:33

if i have getDriversRealtime(), getOrdersListRealtime(), getActiveDriversRealtime(context) i need 3 different realtime = Realtime(client) ?

alex2341355
29 Mar, 2024, 12:34

I thought about it. but that's very bad

alex2341355
30 Mar, 2024, 07:35

nop. it did not help

Steven
1 Apr, 2024, 23:10

how often does this happen? Does it stop happening for a period of time and then comes back randomly?

Steven
1 Apr, 2024, 23:10

It's working fine now, right?

alex2341355
2 Apr, 2024, 07:24

hello. I have now turned off realtime, so I don’t know. But in general, yes, this always happened, after varying amounts of time, both in debug mode and in release. All other api worked fine

kev.
7 Apr, 2024, 00:53

I also have the problem that realtime on flutter is working sporadically. I have a basic realtime subscription to a document and it is not reliable. Sometimes is does fetch the data if the document changed and sometimes it does not.

It happes when you have several websocket connections at the same time. I connected with postman dirctly to the websocket and made a connecton to realtime with the flutter app. This coused the problem that some times the connection with the app worked and sometimes not. The appwrite is hosted on a server and the postmen (on mac) and flutter app on (android phone).

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more