Back

How to know if realtime succeeded or failed when subscribing?

  • 0
  • Flutter
fernandoxlr
7 Mar, 2023, 23:10

I'm building a chat app, and I need to know and show to users when the subscribe connection was stablished. When I use realtime.subscribe without connection I can't detect if it succeeded or failed, because the error of connection is not dispatched to outside of the sdk.

The try catch is never fired nor the stream.onError when trying to subscribe.

This way I can't start a reconnection attempt nor show that the connection was done successfully.

TL;DR
The user is having trouble knowing if a realtime subscription succeeded or failed when subscribing. They mention that the onError and onDone handlers are not being called when trying to subscribe without a connection. They are building a chat app and need to notify users when the subscription connection is established. A potential solution suggested is to add an onError or onDone handler to listen for any output. The user also mentions that they can't start a reconnection attempt or show that the connection was successful.
Drake
7 Mar, 2023, 23:16

Could you try to add an onError or onDone handler to listen and see if that outputs anything?

https://api.flutter.dev/flutter/dart-async/Stream/listen.html

fernandoxlr
8 Mar, 2023, 12:49

@Steven it's what I did, it's on the screenshot attached. Neither onDone nor onError is called.

fernandoxlr
8 Mar, 2023, 12:51

onDone is called when connection is lost. But only after successfully connected previously. But if you try subscribe already without connection, none of the methods is called.

Drake
8 Mar, 2023, 14:36

Sorry! How did I miss that?! 🫒

Drake
8 Mar, 2023, 14:37

It might be good to create an issue in the flutter SDK repo for this

fernandoxlr
8 Mar, 2023, 15:27

Alright

Drake
8 Mar, 2023, 16:17
fernandoxlr
8 Mar, 2023, 19:56
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