1

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!

2
  • Can you please share your server code ? Commented Mar 1, 2018 at 18:32
  • Had the same issue recently, reading all remaining messages before calling Finish() helped. Commented Jul 22, 2019 at 15:05

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.