0

我有一个流数据的 golang 服务器和一个 dart 客户端。我把下面的代码似乎工作正常

var response = stub.streamMusic(RequestMusicId(musicId: musicId));
await for(var v in response) {
    print(v);
}

但是当我尝试使用这个来收听流时

var response = stub.streamMusic(RequestMusicId(musicId: musicId));
response.listen((value) { 
      print(value);
});

即使服务器正在运行,我也会收到以下错误。

Connecting to VM Service at http://127.0.0.1:55936/l3_uHzU_qIw=/
Unhandled exception:
gRPC Error (code: 14, codeName: UNAVAILABLE, message: Error connecting: Connection shutting down., details: null, rawResponse: null, trailers: {})
Exited (255)
4

0 回答 0