Consuming gRPC Server Reflection from C++ Client (that happens to also offer a Server Reflection)

319 views
Skip to first unread message

Alex Stark

unread,
Feb 11, 2019, 6:01:03 PM2/11/19
to grpc.io

This might seem like an odd pattern, but I'm looking to retrofit an existing client/server framework with gRPC.  That has led me to a question and an issue.

FIrst, the question.  The "Use Server Reflection in a C++ Client" secion of the Server Reflection Tutorial  mentions using the grpc::ProtoReflectionDescriptorDatabase class as the basis of that interaction.  That seems to require me to link in libgrpc++_proto_reflection_desc_db.a which as far as I can tell has no "install" option in the makefile provided.  Is staticlly linking it from the grpc/lib/opts directory the recomended pattern or am I missing something?

To try things out I went ahead and linked it into my client/server framework library directly.  However, from there I'm having issues getting my test server to startup when linking in both my client/server dynamic library (that statically links libgrpc++_proto_reflectin_desc_db.a) and libgrpc++_reflection.so.  The error in question is this:

[libprotobuf ERROR google/protobuf/descriptor_database.cc:58] File already exists in database: src/proto/grpc/reflection/v1alpha/reflection.proto
[libprotobuf FATAL google/protobuf/descriptor.cc:1358] CHECK failed: GeneratedDatabase()->Add(encoded_file_descriptor, size):
terminate called after throwing an instance of 'google::protobuf::FatalException'
  what():  CHECK failed: GeneratedDatabase()->Add(encoded_file_descriptor, size):

I'm planning to continue digging in to see if I can figure out why that's an issue, but the comment foujnd in descriptor.cc around this exception throw isn't initial obvious to me (as a novice) what exactly I might be doing wrong.  Hoping the community might have some insight into whether or not those 2 libraries are inherently incompatable inside the same process.  As far as I can tell I don't even get to the creation of the actual ProtoReflectionDescriptorDatabase construction the error happens while the process is starting up.

Thanks in advance for any advice on those topics.

Alex Stark

unread,
Feb 12, 2019, 10:31:29 AM2/12/19
to grpc.io
Upon further debuging it appears the conflict is with /src/proto/grpc/reflection/v1alpha/reflection.pb.cc being included twice.  Which makes sense given the error code.  What I'm not understanding is why that is considered a fatal error.

And of course if there's anyway around it.

WD J

unread,
Dec 7, 2022, 1:52:09 AM12/7/22
to grpc.io
I face the same problem, and the scenoria is Binary A use the grpc++_reflection.a and libB.so first not link the grpc++_reflection.a, build the binaryA, and libB.so recompile with linking the grpc++_reflection.a, then binaryA fatal with the same error information.
Reply all
Reply to author
Forward
0 new messages