Reputation: 975
Are the gRPC examples intended to interoperate? I can run the Java client-server examples entirely with Java. I can Go examples entirely with Go. But Go's hello world client won't talk with Java's hello world server.
In one terminal, from grpc-java:
$ ./gradlew :grpc-examples:helloWorldServer
:grpc-core:compileJava UP-TO-DATE
...
:grpc-examples:helloWorldServer
Mar 10, 2015 7:01:50 PM io.grpc.examples.helloworld.HelloWorldServer start
INFO: Server started, listening on 50051
> Building 96% > :grpc-examples:helloWorldServer
In another terminal, from grpc-common/go
$ go run greeter_client/main.go
2015/03/10 19:02:47 could not greet: rpc error: code = 12 desc = "Method not found: /helloworld.Greeter/SayHello"
exit status 1
Not the cross-language example I was expecting. SayHello is there, but is the problem with path or case sensitivity? Am I missing something, or is this cross-language cooperation an intent not yet realized?
(Caveat--I don't know Go, and I've been unable to build grpc for C++).
Upvotes: 4
Views: 3244
Reputation: 21485
The two examples you are using are based on incompatible proto definitions. The problem is that the java example is using the package name grpc.example.helloworld
and the go example is using just the helloworld
.
And because the package name is part of the URL
path (/helloworld.Greeter/SayHello
) the call fails (the java server is expecting /grpc.example.helloworld.Greeter/SayHello
).
You can see it in the generated code.
Java:
private GreeterServiceDescriptor() {
sayHello = createMethodDescriptor(
"grpc.example.helloworld.Greeter", METHOD_SAY_HELLO);
}
Go:
var _Greeter_serviceDesc = grpc.ServiceDesc{
ServiceName: "helloworld.Greeter",
HandlerType: (*GreeterServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "SayHello",
Handler: _Greeter_SayHello_Handler,
},
},
Streams: []grpc.StreamDesc{},
}
Upvotes: 4