Bad state: StreamSink is closed
furkanKotic opened this issue · comments
The Firebase log record, which is usually seen on Oppo devices, is as follows:
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Bad state: StreamSink is closed
at _WebSocketImpl.add(_WebSocketImpl.java)
at DelegatingStreamSink.add(stream_sink.dart:35)
at _CompleterSink.add(sink_completer.dart:88)
at WebSocketChannelExtension.sendData(channel.dart:20)
at Transport.sendAsyncMessage(transport.dart:162)
at ClientImpl._onPing(client.dart:711)
at ClientImpl._onPush(client.dart:719)
at Transport._onData.<fn>.<fn>(transport.dart:266)
at _GrowableList.forEach(_GrowableList.java)
at Transport._onData.<fn>(transport.dart:262)
I think it is seen in the application that is pending in the background.
You need to close client when app goes to the background. See https://github.com/centrifugal/centrifuge-dart#usage-in-background
I should use disconnect when it goes to the background and use the connect function again when it goes to the foreground. Is it true?
Should I cancel all Stream when it goes to the background and recreate them when it goes to the foreground?
_imClient.connected.listen((event) {
**my code
});
I should use disconnect when it goes to the background and use the connect function again when it goes to the foreground. Is it true?
Yes
Should I cancel all Stream when it goes to the background and recreate them when it goes to the foreground?
I think you don't need to do this.
Thank you for your help.