dart-lang / web_socket_channel

StreamChannel wrappers for WebSockets.
https://pub.dev/packages/web_socket_channel
BSD 3-Clause "New" or "Revised" License
424 stars 112 forks source link

FormatException: Unexpected character #337

Closed gghh0408 closed 7 months ago

gghh0408 commented 7 months ago

hello。

Sometimes websocket will report the following error:

error=FormatException: Unexpected character (at character 1) ac6bae460ef86c5910565b897cda7997/null/run ^

or

error=FormatException: Unexpected character (at character 1) ac6bae460ef86c5910565b897cda7997/null/wait ^

this is my code ↓:

  runZonedGuarded(() {
      _channel = IOWebSocketChannel.connect(wsUrl!, headers: headers, connectTimeout: Duration(seconds: 6));
      _channel?.stream.listen((event) {
        if (_channel == null) {
          return;
        }
        if (event is String) {
          resolveWSReturn(event);
        }
      }, onError: _webSocketOnError, onDone: _webSocketOnDone, cancelOnError: true);
    }, (error, stack) {
      print("error=$error");
      _webSocketOnError();
    });

I have looked at the source code and do not see such a print。 how i can fix it? Or maybe this is actually a server error?