Back

[SOLVED] Multiple realtime channels with Account

  • 0
  • Flutter
  • Realtime
Disk_MTH
24 Sep, 2023, 15:05

Hello everyone,

I've been using Appwrite recently, and I have a question regarding realtime that I haven't found an answer to in the documentation.

First of all :

When I initialize my app, I create a "RealtimeSubscription" on "account". I add a listener to react to account changes, and I "close()" / recreate the "RealtimeSubscription" at each login / logout (as specified in the documentation). This whole part works perfectly.

Afterwards :

When the user opens a page with data that must be updated in real time, I create a "RealtimeSubscription" which manages the change in certain documents in the database. This whole part works perfectly.

My issue is the following:

When I open the updated page in realtime, the user part disconnects instantly, and it's the same for the realtime of the page. I have console messages "subscription null" alos that I absolutely did not want the disconnection.

I think I have a poor understanding of Realtime on this aspect of channel/subscription, can you enlighten me?

Sincerely, Disk_MTH

TL;DR
The user is experiencing issues with their RealtimeSubscription in the Appwrite framework. They have successfully implemented the subscription for account changes, but when they try to open a page with real-time data updates, the user and page subscriptions get disconnected instantly. The user is looking for clarification on how to properly manage channels and subscriptions in Realtime. Solution: It is suggested to create a singleton instance of `Realtime(client)` and use it throughout the app to prevent disconnection issues. Also, make sure to check if the appwrite version and SDK are up to date.
darShan
24 Sep, 2023, 16:00

Platform?

Disk_MTH
24 Sep, 2023, 16:06

Flutter, it's in the tag post πŸ˜‰

Disk_MTH
24 Sep, 2023, 16:07

Some words in your desc are in French, do you speak french ?

darShan
24 Sep, 2023, 16:11

my bad, i missed it.

Disk_MTH
24 Sep, 2023, 16:11

no problem

darShan
24 Sep, 2023, 16:12

no, btw I don't see anything french though in my profile's desc πŸ˜…

Disk_MTH
24 Sep, 2023, 16:12

my bad the word "Entrepreneur" is the same in both English and French

Disk_MTH
24 Sep, 2023, 16:13

but as French preople it doesn't sound as a English term

darShan
24 Sep, 2023, 16:13

Could you try creating a singleton of Realtime(client) & use that instance across app & see if the disconnection still happens?

I've seen this in apple sdk quite a few times randomly.

darShan
24 Sep, 2023, 16:15

Also, appwrite 1.4x with latest sdk?

Disk_MTH
24 Sep, 2023, 16:15

I've a singleton of Realtime, and I use only this singleton but when I try to subscribe to two channels in the same class, it work, both are updated, but if on is declared, and another when the page show up, both are killed and I dont understand why

Disk_MTH
24 Sep, 2023, 16:16

on my pubspec.yaml : appwrite: ^11.0.0

Disk_MTH
24 Sep, 2023, 16:16
darShan
24 Sep, 2023, 16:41

Can you try using subscribe with multiple channels with a singleton subscription? Does that work?

Disk_MTH
24 Sep, 2023, 16:45

This is what I had thought of using first (it seemed logical to me) but it was when I saw the documentation which said that at each connection/disconnection, it was necessary to stop the realtime and recreate it that I said to myself that I was going to separate the different streams. So I just remerged everything and it works for now (I haven't finished everything yet). On the other hand, contrary to the documentation, I do not need to recreate my channel each time to always have the updates. I'll continue and post if it's definitely fixed or not.

Drake
25 Sep, 2023, 05:18

There might still be a bug with the flutter SDK and realtime. For now, can you try using separate realtime instances for each subscription?

Disk_MTH
25 Sep, 2023, 07:56

That's what I tested basically, and that's what's the problem. I did otherwise: I made 1 single realtime that makes both my accounts and my collections and at each change of account status, I re-call "listen" on my realtime and it works

Disk_MTH
25 Sep, 2023, 18:38

[SOLVED] Multiple realtime channels with Account

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