centrifugal / centrifuge-dart

Dart (Flutter) client SDK for bidirectional communication with Centrifugo and Centrifuge-based server over WebSocket

Home Page:https://pub.dartlang.org/packages/centrifuge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot add new events after calling close

furkanKotic opened this issue · comments

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);
    }
  }

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

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