felangel / web_socket_client

A simple WebSocket client for Dart which includes automatic reconnection logic.
https://pub.dev/packages/web_socket_client
MIT License
150 stars 32 forks source link

fix: Cannot add new events after calling close #17

Closed MaxiStefan closed 1 year ago

MaxiStefan commented 1 year ago

Description

Open a socket, listen to messages, run socket.close();

Steps To Reproduce

  1. Open a socket
  2. Await the Connected state
  3. Listen to messages (2-3 msgs / sec) and print(event)
  4. Close socket

Expected Behavior

Socket closes peacefully.

Screenshots

I/flutter (27831): Bad state: Cannot add new events after calling close I/flutter (27831): #0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:243:24) I/flutter (27831): #1 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10) I/flutter (27831): #2 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) I/flutter (27831): #3 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) I/flutter (27831): #4 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11) I/flutter (27831): #5 _HandleErrorStream._handleData (dart:async/stream_pipe.dart:253:10) I/flutter (27831): #6 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13) I/flutter (27831): #7 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10) I/flutter (27831): #8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) I/flutter (27831): #9 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) I/flutter (27831): #10 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19) I/flutter (27831): #11 _StreamController._add (dart:async/stream_controller.dart:648:7) I/flutter (27831): #12 _StreamController.add (dart:async/stream_controller.dart:596:

Additional Context

Add any other context about the problem here.

endmr11 commented 1 year ago

I have same issue

abdooobsl commented 1 year ago

I have same issue

edkennard commented 1 year ago

I have the same issue, there's a PR which attempts to fix it, https://github.com/felangel/web_socket_client/pull/18 , @felangel any chance of this being reviewed and merged?

felangel commented 1 year ago

I have the same issue, there's a PR which attempts to fix it, #18 , @felangel any chance of this being reviewed and merged?

Yup sorry for the delay! I’ll try to get this merged this evening.

edkennard commented 1 year ago

@felangel Thanks very much!!