Back

Many realtime

  • 0
  • Flutter
  • Realtime
Mickaël LT
30 May, 2023, 13:31

Hi, I've many realtime provider on my app, but something some of them return null when subscribing, so I never get any update.

I use riverpod for managing my provider. I've found a way to solve it by creating many instance for my realtime provider, but I don't know if it is a good practice.

Can I create many realtime client like this : final realtime = Realtime(client); and create a subscription

Or the best way is to create only one client and many subscription ?

TL;DR
TL;DR: The user is experiencing issues with null subscriptions on their client, but the server logs show successful connections. They are advised to check the logs for any errors and consider upgrading their instance. It is recommended to create one client with multiple subscriptions rather than creating multiple instances of the client.
Binyamin
30 May, 2023, 13:40

Every time you're running.

TypeScript
final realtime = Realtime(client);

You're creating a new socket to your server which can become overwhelming pretty fast. https://github.com/appwrite/sdk-for-flutter/blob/master/lib/src/realtime_io.dart#L35

I think the best way would be one client with multiple subscriptions, and check each time what you got. And in case you got null / empty ones just ignore them.

Mickaël LT
30 May, 2023, 13:45

Yes, but when I do this, some subscription return me null and I never get notified :/

Binyamin
30 May, 2023, 13:47

You get a completely null? like all the is just null?

Mickaël LT
30 May, 2023, 13:51

Yes, in the log, i got only "subscription : null", it come from this line : "debugPrint('subscription: $_lastUrl');" in the method _createSocket in the class RealtimeMixin.

Binyamin
30 May, 2023, 13:52

Are you running against Appwrite cloud or a self-hosted one?

Mickaël LT
30 May, 2023, 14:04

self hosted (1.2.1)

Binyamin
30 May, 2023, 14:10

So you can run

TypeScript
  docker logs appwrite-realtime

To see if any obvious errors are shown.

Also, when you can backup, and upgrade your instance. (using migration scripts)

Mickaël LT
30 May, 2023, 14:13

Yes, it is planned, i'll do that next week 🙂

Binyamin
30 May, 2023, 14:15

Have you seen anything suspicious in the logs?

Mickaël LT
30 May, 2023, 14:42

I've just receive a null subscription on my client, but on the server, nothing warm me : Connection open (user: 2025) Connection open (user: 2026) Connection open (user: 2027) Connection open (user: 2028) Connection close: 2020 Connection open (user: 2029) Connection open (user: 2030) Connection close: 2030 Connection open (user: 2031) Connection close: 2031 Connection close: 2029 Connection open (user: 2032) Connection close: 2025 Connection close: 2028 Connection close: 2026 Connection close: 2027 Connection open (user: 2033) Connection open (user: 2034) Connection open (user: 2035) Connection open (user: 2036) Connection open (user: 2037) Connection close: 2035 Connection open (user: 2038) Connection close: 2038 Connection open (user: 2039) Connection close: 2037 Connection open (user: 2040) Connection close: 2040 Connection open (user: 2041) Connection open (user: 2042) Connection open (user: 2043) Connection close: 2036 Connection close: 2033 Connection close: 2034 Connection close: 2039 Connection open (user: 2044) Connection close: 2043 Connection close: 2042 Connection close: 2041 Connection open (user: 2045) Connection close: 2044 Connection open (user: 2046) Connection close: 2046 Connection open (user: 2047) Connection open (user: 2048) Connection open (user: 2049) Connection open (user: 2050) Connection open (user: 2051) Connection close: 2051 Connection open (user: 2052) Connection open (user: 2053) Connection open (user: 2054)

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