Grpc-go: grpc_cli does not work if proto file contains google.protobuf.Timestamp

Created on 1 Apr 2017  路  4Comments  路  Source: grpc/grpc-go

(Copying from grpc/grpc#10304)
(Vaguely related to https://github.com/golang/protobuf/issues/298)

I have a proto file like this for my gRPC definition:

 syntax = "proto3";
 import "google/protobuf/timestamp.proto";

and Service definitions which use google.protobuf.Timestamp type to store timestamps.

I am compiling my program to Go using grpc-go and trying to reflect on it using grpc_cli.

$ ./grpc_cli ls localhost:8001
UserDirectory
grpc.reflection.v1alpha.ServerReflection

This works but when I try to go into detail I get errors about google.protobuf.Timestamp

$ ./grpc_cli ls localhost:8001 UserDirectory -l
[libprotobuf ERROR google/protobuf/descriptor.cc:3422] Invalid proto descriptor for file "coffeelog.proto":
[libprotobuf ERROR google/protobuf/descriptor.cc:3425]   coffeelog.proto: Import "google/protobuf/timestamp.proto" was not found or had errors.
[libprotobuf ERROR google/protobuf/descriptor.cc:3425]   PostActivityRequest.Date: "google.protobuf.Timestamp" seems to be defined in "github.com/golang/protobuf/ptypes/timestamp/timestamp.proto", which is not imported by "coffeelog.proto".  To use it here, please add the necessary import.
(and more...)

I am successfully able to get grpc_cli to do ls -l on the helloworld.GreeterServer sample program on grpc-go: https://github.com/grpc/grpc-go/blob/master/examples/helloworld/helloworld/helloworld.proto since it doesn't contain the google.protobuf.Timestamp.

Any ideas?

Most helpful comment

Seems this will be an issue with all google.protobuf.* well-known protos, not just timestamp.proto

All 4 comments

I'm having the same problem. As a when calling grpc_cli call ... I now use the following extra arguments:

--proto_path=.grpc/third_party/protobuf/src/ --protofiles=.grpc/third_party/protobuf/src/google/protobuf/timestamp.proto

Here .grpc is the directory where I checked out the grpc source code.

This does not work for grpc_cli ls though, because it doesn't support these extra options.

Seems this will be an issue with all google.protobuf.* well-known protos, not just timestamp.proto

This is an issue with the grpc_cli tool and is tracked here: grpc/grpc#10304
Closing the issue here.

get protoc release (any platform ) and copy the protos files in include directory to $GOROOT\pkginclude, then should work.

Was this page helpful?
0 / 5 - 0 ratings