Back

Stream<RealtimeMessage> subscription returns null everytime.

  • 0
  • Databases
  • Flutter
  • Realtime
DennisLBC
14 Dec, 2023, 17:56

I have a working stream for one of my collections, but setting up the second one never works. Logging for my first stream that works look like:

TypeScript
First Stream: Instance of '_BroadcastStream<RealtimeMessage>'
I/flutter (24668): AppwriteRealtime: Allow self-signed certificate
I/flutter (24668): subscription: wss://cloud.appwrite.io/v1/realtime?project=************

I can see the subscription activated and it works as intended. On the second one, I am following the exact same process and just feeding a different collection:

TypeScript
@override
  Stream<RealtimeMessage> getLatestProfile() {
    final stream = _realTime.subscribe([
      'databases.${AppWriteConstants.databaseId}.collections.${AppWriteConstants.usersCollectionId}.documents'
    ]).stream;
    print('Stream $stream');
    return stream;
  }

Second Stream: Instance of '_BroadcastStream<RealtimeMessage>'
I/flutter (24668): AppwriteRealtime: Allow self-signed certificate
I/flutter (24668): subscription: null

The subscription just returns null everytime. Not sure if it matters, but I have confirmed both collections have the same permissions, and ensured I don't have any typos and the database/collection Ids are infact correct, I've even tried hard coding them.

TL;DR
TL;DR: The user is experiencing an issue where the subscription to a second stream returns null every time. The user has tried creating multiple instances and using a workaround, but the issue persists. It seems to be a bug with the flutter SDK. The user has provided code snippets and links to relevant resources.
Drake
14 Dec, 2023, 18:21

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

Drake
14 Dec, 2023, 18:24

There's a bug with the flutter SDK and making multiple subscribe calls

DennisLBC
14 Dec, 2023, 18:44

It looks like this has been an active bug since June, half a year is quite some time. I tried the work around of created a second instance and that did solve the problem, so it's definitely this issue.

punti_z
15 Dec, 2023, 12:54

What was your work around. I myself am struggling with this

DennisLBC
15 Dec, 2023, 18:05

I posted the solution, it's just to create a second instance. In my case, I have like 5 different instances now that I have numbered sort of annoying but it works.

punti_z
15 Dec, 2023, 22:03

Odd, even separate instances are not particularly reliable for me. I chalked it up to single websocket being disrupted if I add new instances so I currently have just one that includes everything I want yo monitor and if(event) everywhere I use the trigger..

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