https://github.com/dart-lang/web_socket_channel/issues/38

 

yes, my workaround is to create a WebSocket directly. Something like:

      final socket = await WebSocket
          .connect(url.toString())
          .timeout(_webSocketConnectionTimeout);
      return IOWebSocketChannel(socket);

Then I wrap this in a try-catch, so I can catch SocketException and TimeoutException and handle these in a way that makes sense for my app.

 

 

 the following way works for me:

      stream = widget.webSocketChannel.stream;
      streamSubscription = stream.listen(
          onData,
          onError: (error) {
             // method calls and what not here
          },
          cancelOnError: true);
    }

I don't know if it is working because I have a StreamSubscription or whether it simply is an additional step.

 

相关文章:

  • 2022-01-22
  • 2021-12-11
  • 2021-09-29
  • 2021-09-19
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
猜你喜欢
  • 2022-02-25
  • 2021-11-22
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2021-12-15
  • 2021-06-12
相关资源
相似解决方案