
i used the subscription.close but still socket connection remains open. my aim is to refresh connections if a team is created , user is added to the team and all permission of the document is given to that team. but while creating that document invocation is not sent to that users in the team. (All collection permission is create to all user).

Hi, any chance you could show me your code?

ok , i have made a test code. which basically refresh connection every 5 seconds . its just for testing purpose. before refreshing previous connection is closed.

getSavedData() async { await sessionCreate(context, true, 95620444); const oneSec = Duration(seconds: 5); Timer.periodic(oneSec, (Timer t) async { //printIps();
// if (subscription != null) {
try {
subscription!.close();
} catch (e) {
print(e);
}
// }
create(context);
});
}

create(BuildContext context) async { final realtime = Realtime(client!); //RealtimeSubscription subscription; try { subscription = realtime.subscribe([ 'databases.62f21a94d3a40d60445b.collections.62a899742200380b8ca7.documents' ]); subscription!.stream.listen( (data) { print(data.payload); if (data.payload.isNotEmpty) { List<dynamic> ev = data.events; print(ev.elementAt(0)); String b = ev.elementAt(0); switch (data.events.elementAt(0)) { case 'databases.62f21a94d3a40d60445b.collections.62a899742200380b8ca7.documents..create': var item = data.payload; print(item); print("items added"); break; case "databases.62f21a94d3a40d60445b.collections.62a899742200380b8ca7.documents..delete": var item = data.payload; print(item); print("items deleted"); break; case "databases.62f21a94d3a40d60445b.collections.documents.update": var item = data.payload; print(item); print("items updated"); break; default: break; } } }, onDone: () { print("test"); }, ); //subscription!.close(); } catch (eee) { print(eee); } }

so how many times are you calling realtime.subscribe()
? just once?

btw, for multi-line code, it's best to wrap with 3 backticks and include the language like https://www.markdownguide.org/extended-syntax/#syntax-highlighting

it also called multiple times

using the same realtime instance?

code is in flutter, realtime is declaration is outside timer.

so you use that realtime
instance and call realtime.subscribe()
multiple times?

yes

So the websocket will remain open unless all subscriptions are closed. If you have multiple subscriptions, you could be running into race conditions where it seems like not all closed , but they all did
Recommended threads
- Sites 30MB limit from GitHub
I’m deploying a site from github as Other type on the Hobby plan. It is actually a Flutter web app but it’s in a subdirectory with the root being an html landin...
- [Node.js SDK] Bypass 2GB file limit?
Hello. Using either InputFile.fromPath or InputFile.fromBuffer throws this error: File size (2295467305) is greater than 2 GiB Bucket limit etc. is setup corre...
- Hi im using vvs studio to make a charact...
my game involves magic , leveling up aka "phase" max phase is 30 each 10 20 30 theres awakening 1 2 3 i want to make a character builder so that players can fig...
