Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket Ping Interval Raises Bad state: Cannot add event after closing #37441

Closed
putraxor opened this issue Jul 4, 2019 · 2 comments
Closed
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@putraxor
Copy link

putraxor commented Jul 4, 2019

WebSocket Ping Interval Raises Bad state: Cannot add event after closing

Source:

    var url = 'wss://stream.binance.com:9443/ws/!miniTicker@arr';
    _webSocket = await WebSocket.connect(url).catchError((e) {
      print('Failed to connect to $url because $e retry in 5 seconds');
    });
    _webSocket?.pingInterval = Duration(minutes: 2);
    _webSocket?.listen((data){
        print(data);
     });

Trace Logs:

#0      _StreamController.add (dart:async/stream_controller.dart:585:24)
#1      _WebSocketConsumer.add (dart:_http/websocket_impl.dart:953:17)
#2      new _WebSocketImpl._fromSocket.<anonymous closure> (dart:_http/websocket_impl.dart:1133:38)
#3      _rootRunUnary (dart:async/zone.dart:1132:38)
#4      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#5      _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#8      _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#9      _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#10     _WebSocketProtocolTransformer._startPayload (dart:_http/websocket_impl.dart:310:24)
#11     _WebSocketProtocolTransformer._lengthDone (dart:_http/websocket_impl.dart:290:7)
#12     _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:194:13)
#13     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)

This tracker is for issues related to:

  • Dart core libraries ("dart:async", "dart:io", etc.)
dart --version
Dart VM version: 2.2.0 (Tue Feb 26 15:04:32 2019 +0100) on "macos_x64"
@a-siva a-siva added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) library-io labels Jul 8, 2019
@zichangg
Copy link
Contributor

I didn't reproduce it locally. It looks like websocket received a ping and tries to response it with a pong but it is closed at that time. Is it easy to reproduce?

@zichangg
Copy link
Contributor

The same issue: #37417

dart-bot pushed a commit that referenced this issue Jul 16, 2019
ping/pong mechenism will send reponse without checking whether stream controller is closed or not.

Bug: #37441
Change-Id: Iaaec052a6ad82f1bccf7a50a646867665c7e9e8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109304
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants