centrifugal / centrifuge-dart

Dart (Flutter) client SDK for bidirectional communication with Centrifugo and Centrifuge-based server over WebSocket
https://pub.dartlang.org/packages/centrifuge
MIT License
102 stars 29 forks source link

Cannot add new events after calling close #77

Closed furkanKotic closed 1 year ago

furkanKotic commented 1 year ago

I saw this error on Firebase. I am trying to unsubscribe channel.

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Bad state: Cannot add new events after calling close
       at _BroadcastStreamController.add(_BroadcastStreamController.java)
       at SubscriptionImpl._addUnsubscribe(subscription.dart:244)
       at SubscriptionImpl.moveToUnsubscribed(subscription.dart:173)
       at IMController.unsubscribe(im_controller.dart:157)

this is my unsubscribe code:

  Future<void> unsubscribe(String channel) async {
    var a = _imClient.getSubscription(channel);
    if (a != null) {
      await a.unsubscribe();  //line 157
      _imClient.removeSubscription(a);
    }
  }
FZambia commented 1 year ago

Hello @furkanKotic - please provide reproducing example in the style of console example we have.

furkanKotic commented 1 year ago

I don't have an example. I can't find how this happened. I think we will not find the problem.