I am trying to use ClientBidiReactor<TRequest, TResponse> to build a GRPC 
client with bidirectional async streaming using the callback api approach. 
Everything works fine when I use a type generated from my proto file for 
TRequest and TResponse. But when I try to use grpc::ByteBuffer as TRequest 
and TResponse type, I see the WritesDone call back is invoked with true 
value, but the server never receives the grpc call.

Let me elaborate:
I have a simple proto definition 

message GreeterMessage {
    string message = 1;
}

service GreeterService {
  rpc GreetStream (stream GreeterMessage) returns (stream GreeterMessage) {}
}

Here is the working version where I am using the generated GreeterMessage 
type 

class GrpcWorker1 : public grpc::ClientBidiReactor<GreeterMessage, 
GreeterMessage> {
public:
    explicit GrpcWorker1(std::shared_ptr<Channel> channel) {

        std::unique_ptr<GreeterService::Stub> 
stub_(GreeterService::NewStub(channel));
        stub_.get()->async()->GreetStream(&context_, this);

        GreeterMessage* msg = new GreeterMessage();
        msg->set_message("Start");
        StartWrite(msg);

        StartRead(&messageFromServer_);
        StartCall();
    }

On my server side (aspnet core grpc service) which uses same proto file, I 
can see this request arriving.

Now I want to send ByteBuffer type data from my client app instead of 
StreamingMessage as another part of my app already has the data in 
ByteBuffer form. So I wrote another version of this class using generic 
stub to avoid the extra de-serialization step(bytebuffer -> GreeterMessage 
type).

 class GrpcWorker2 : public grpc::ClientBidiReactor<ByteBuffer, ByteBuffer> 
{
public:
    explicit GrpcWorker2(std::shared_ptr<Channel> channel) {

        generic_stub_ = absl::make_unique<GenericStub>(channel);

        const char* suffix_for_stats = nullptr;
        cli_ctx_ = absl::make_unique<ClientContext>();
        StubOptions options(suffix_for_stats);
        generic_stub_->PrepareBidiStreamingCall(
            cli_ctx_.get(), "GreetStream", options, this);
            
        request_.set_message("test_str");
        send_buf_ = SerializeToByteBuffer(&request_);
        StartWrite(send_buf_.get());

        StartRead(&readMessageByteBuffer_);
        StartCall();
    }

Both implementations listen to the "OnWriteDone" callback where I see value 
1 for the ok parameter when the code is executed. But the server never 
receives the message for the second implementation GrpcWorker2.

Here is the full repro of client app if that 
helps: 
https://github.com/kshyju/ClientBidiReactorByteBufferDemo/tree/master/GreeterServiceClient

What am I missing in GrpcWorker2 ? Is there a better way to do this?

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/d1a88f4d-750f-49e2-8b50-0b5ce35169afn%40googlegroups.com.

Reply via email to