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!
Finish()
helped. – archo