Back

How to know if Realtime successfully started listening?

  • 0
  • Flutter
  • Realtime
  • Cloud
memoonlite
15 Mar, 2024, 12:18

Hello everyone!

I'm using the following sample code to establish a Realtime connection from within my Flutter app:

TypeScript
/// final realtime = Realtime(client);
/// final subscription = realtime.subscribe(['collections']);
/// subscription.stream.listen((event) {
///   print(event);
/// });
///
/// subscription.close();
/// ```

Most of the times it works well, but sometimes (randomly) the connection isn't establish. No exception is thrown when that happens and there is nothing in the logs. This is very frustrating because it breaks functionality.

Does anyone know how to detect if a Realtime connection is properly working from within code?
TL;DR
Developers are experiencing issues detecting if a Realtime connection is successfully established in their Flutter app using Appwrite. The problem occurs randomly without any exceptions or error messages. They are seeking guidance on how to ensure the connection is working as expected. One developer shared sample code showing how they were setting up the Realtime connection. Potential Solution: - One developer recommended checking the Flutter logs for specific messages to determine the status of the Realtime connection. They shared that a successful connection typically shows specific messages in the logs, while a failed connection may lack those messages. This could help in diagnosing when the connection isn't established correctly. - Another
memoonlite
15 Mar, 2024, 12:19

How to know if Realtime successfully started listening?

Faye
15 Mar, 2024, 12:26

Are you using cloudflare?

memoonlite
15 Mar, 2024, 12:28

No, just Appwrite Cloud without having anything in front of it.

memoonlite
15 Mar, 2024, 12:31

Logcat shows this when the connection is working correctly:

TypeScript
I/flutter (17316): subscription: wss://cloud.appwrite.io/v1/realtime?project=xxxxxxxxxxxx&channels%5B%5D=databases.xxxxxxxxxxxxxxx.collections.xxxxxxxxxxxx.documents```

But when it's not working it just shows this:

```I/flutter (17316): AppwriteRealtime: Allow self-signed certificate```
memoonlite
15 Mar, 2024, 12:31

Somewhere it fails to connect, but there is no exception and onDone isn't called either.

Faye
15 Mar, 2024, 12:32

I sadly do not know enough using dart, but maybe someone else can help soon πŸ™‚

Faye
15 Mar, 2024, 12:32
memoonlite
15 Mar, 2024, 12:35

Thanks for thinking along either way. πŸ‘πŸ»

memoonlite
15 Mar, 2024, 12:35

Yeah, there is nothing in the documentation that points me in the right direction. The problem is that it happens completely randomly. And these are the programming problems I hate, because they are hard to debug.

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