Hello, In Flutter, after disposing my listeners, the console still shows the connections, what might be wrong?
@override
Future<RealtimeSubscription> getDoctorModelRealtimeSubscription(
DoctorModel value) async {
final rt = realtime.subscribe([
'databases.$DatabaseId.collections.$DoctorsCollectionId.documents'
]);
return rt;
}
....
StreamSubscription? _sub;
Future<void> _startRealtimeSubscription() async {
if (state.documentId.isEmpty || !mounted) return;
final realtimeSubscription =
await AsyncValue.guard(() => getDoctorModelRealtimeSubscription(state));
if (realtimeSubscription is AsyncData<RealtimeSubscription>) {
_sub = realtimeSubscription.value.stream.listen(_onRealtimeMessage);
}
}
@override
void dispose() {
_sub?.cancel();
super.dispose();
}
Are you using Appwrite cloud?
self hosting
What version?
1.3.7
Same version as I'm using 👀
I had something similar in flutter. Connection was cancelled but it remained
It's a weird behavior, I'm certain of my dispose methods but the connection is still there
If you close the app completely it stops?
a hot restart resets things yes
@D5 have you spent time around this issue?
Realtime Connections in Flutter do not get disposed!
I just found out thru some experiment that the following solves the issue
...
realtimeSub = realtimeSubscription.value;
...
realtimeSub?.close();
@D5 see if this can also solve yours.
Since up to 40 users connected through web simultaneously (the js app worked without issues) and there was only 1 flutter app user, sincerely I ignored the issue 😆
Seems it solves too
this one with leaky streams was already in production, I had to find a solution
but its fine as long as we dont have a million users simultaneously connecting lol
I'm marking this as solved then
[SOLVED] Realtime Connections in Flutter do not get disposed!
Recommended threads
- Flutter OAuth2 webAuth Bug?
I created with flutter an app where I can login in with my Microsoft Account. When I compile it to Web (WASM) or Android (aab) then there is no problem what so ...
- Fine grained permissions for webRTC hand...
Hi, I am building a WebRTC P2P app for a university project and have hit a security limitation regarding permissions for anonymous users. The Architecture: We ...
- Synchronous Function Execution Timed Out...
Hi Appwrite team 👋 I’m facing a synchronous function execution timeout issue on Appwrite Cloud and would appreciate some guidance. I executed this function u...