dragon7088 2018-02-22 03:46
浏览 239

GRPC C ++客户端finish()永远被Golang服务器阻止

I have a C++ gRPC client and Golang gRPC server. For a bi-directional stream, when the client wants to close the stream, it blocks forever on the call to Finish().

This only happens if there is no error, that is, the server rpc function returns nil. If the server was written in C++, I understand it would have returned Status::Ok.

If the Golang server returns a non-nil error, then the Finish() function returns as expected. The problem occurs only in the case of no error.

Example:

.proto

service StreamTest {
  rpc Get(stream StreamCommand) returns (stream Result) {}
}
message StreamCommand{
  string cmd = 1;
}
message Result {
  string res = 1;
}

.cpp

std::unique_ptr<ClientReaderWriter<StreamCommand, Result>> readerWriter;
bool Get(Result &res) {
    return readerWriter->Read(&res);
}

bool CloseClient() {
    StreamCommand cmd;
    cmd.set_cmd("stop");
    readerWriter->Write(cmd);
    readerWriter->WritesDone();
    Status status = readerWriter->Finish(); // <------ BLOCKING
    return status.ok();
}

I have tested the server with a Golang gRPC client and it works fine. Should the server return something other than a nil error? Should I report this as a bug?

Any help is appreciated! Thanks!

  • 写回答

1条回答 默认 最新

  • doumei7420 2018-03-01 16:14
    关注

    I am not familiar with Go, but I know c++ layer. Can you run the client with GRPC_VERBOSITY=debug and GRPC_TRACE=api? That would give more insight into the problem.

    评论

报告相同问题?

悬赏问题

  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输