gRPC c++ v1.38 async-server crashes

481 views
Skip to first unread message

Frank Xie

unread,
Jun 1, 2023, 5:53:06 PM6/1/23
to grpc.io
Hi, 

I am new to gRPC. I am trying to follow the example code ( for some unclosed reason, we have to use version gRPC v1.38),
 at https://github.com/grpc/grpc/blob/v1.38.x/examples/cpp/helloworld/greeter_async_server.cc to implement an asynchronous gRPC server with extra complexity in that the server will send multiple responses (aka,  stream) to gRPC client. 

the proto is something like

rpc  MyRequest (ReqMsg) returns (stream RespMsg)

Basically, when the gRPC server receive client request, it needs *asynchronously* get the info from somewhere else. When the required info comes back (via callback from a different thread, but multiple times), the callback function then *write back* the response using the data structure maintained in CallData,, aka, responder ,etc.  During my testing,  my gRPC server crashes at proto_buffer_writer.h assertion failed !byte_buffer->Valid() after writing back 2 or 3 responses. I am wondering whether it is due to diff thread (other than the thread which block-waiting on gRPC communication) is doing the writing. 

Any advice is appreciated.

Frank

Christian Rivasseau

unread,
Jun 2, 2023, 3:03:47 AM6/2/23
to Frank Xie, grpc.io
Hi Frank,

There can only be a single concurrent write at a time, so you need to wait until you see the TAG* of the previous
write and then you can write again.


--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/22e8fcef-d9eb-4b54-a3f7-2325ea2c3be5n%40googlegroups.com.


--



The influencer marketing platform for lifestyle brands
CHRISTIAN RIVASSEAU
CTO
+33 6 67 35 26 74
lefty.io LinkedIn

Frank Xie

unread,
Jun 4, 2023, 10:43:01 PM6/4/23
to Christian Rivasseau, grpc.io
Hi, Christian,

Thanks lot, it worked. 
Frank
Reply all
Reply to author
Forward
0 new messages