4

I have a simple gRPC app. I have 2 proto files.

1. greet.proto

syntax = "proto3";
import "protos/common.proto";
option csharp_namespace = "Module.SubModule.API";
package greet;

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply);
}

message HelloRequest {
  string name = 1;
}

message HelloReply {
  string message = 1;
  Error error = 2;
}

2. common.proto

syntax = "proto3";
option csharp_namespace = "Module.SubModule.API";
package greet;

message Error {
    int32 status_code = 1;
}

File Structure

Project File Structure

Project File Entry

  <ItemGroup>
    <Protobuf Include="Protos\common.proto" GrpcServices="Server" />
    <Protobuf Include="Protos\greet.proto" GrpcServices="Server" />
  </ItemGroup>

When I run the app and then use grpcui localhost:5001, I get the below error message

Failed to compute set of methods to expose: Symbol not found: greet.Greeter
caused by: File not found: protos/common.proto

Can anyone help out here? The common.proto file is in the same directory and the app runs fine without any build errors. But when using gRPCUI, I get this.

Shahzad
  • 1,677
  • 1
  • 12
  • 25

1 Answers1

0

It could be a server reflection issue. Looking at the readme on github - Proto Source Files it says about including an import path for dependecies to be included correctly, if server relection isn't supported.

This article might help too gRPC Server Reflection in the .NET world

newky2k
  • 419
  • 5
  • 12
  • Yeah, looks like a reflection issue. I have read the above links already. The problem is the docs are very minimal and not much is available on the web too. I tried a lot of combinations but did not get them to work. – Shahzad Jul 11 '21 at 12:35
  • I know this is going to sound obvious, but have you tried matching the case on the "Protos" folder in the import declaration? Somethings can be quite picky about that. – newky2k Jul 11 '21 at 12:41
  • Also, what happens if you put Error straight into the Greeter file without the import. Does it work then? – newky2k Jul 11 '21 at 12:42
  • Yes, I tried to match that. Same issue. Yes, if they are in the same file it works. The issue is with the common file not being imported somehow. – Shahzad Jul 12 '21 at 09:22
  • Ok last through of the dice -> https://github.com/grpc/grpc/blob/master/doc/csharp/server_reflection.md – newky2k Jul 12 '21 at 09:53
  • 1
    I went through this too :) Searched for a way to customize the reflection service, but to no avail. Thanks for the efforts though! – Shahzad Jul 13 '21 at 09:12