Please see the FAQ in our main README.md, then answer the questions below before
submitting your issue.
Can't determine
go version)?go1.11.6 linux/arm
Linux raspberrypi 4.19.58-v7+ (Raspbian GNU/Linux 10 buster)
go get -u google.golang.org/grpccould not greet: rpc error: code = Unimplemented desc = unknown service helloworld.Greeter exit status 1[UPDATE] The error is also reproduced when the server and the client are run on a general Linux PC. The server is run embedded in another application and I can trace from the logs that the Serve method has been called successfully by the server. The client is run by directly executing the main.go in google.golang.org/grpc/examples/helloworld/greter_client/
I'm uncertain as to whether this error is from the server side or the client side?
Client to be able to greet the server successfully
could not greet: rpc error: code = Unimplemented desc = unknown service helloworld.Greeter exit status 1
Hi @niketagrawal,
Did you build the binaries on the Pi, or did you build them on a different machine?
I cross compiled binaries for Pi on a different machine.
Can you try running greeter client against greeter server, without the larger code base, on Pi and see if it succeeds?
@canguler The greeter client and server example works fine if run by itself on the Pi. I'd like to know specifically what does the error could not greet: rpc error: code = Unimplemented desc = unknown service helloworld.Greeter exit status 1 means exactly?, so that there I an get some clue on how to debug it.
Does it have anything to do with the fact that the .pb.go files for server and client is generated separately? The parent .proto file is the same for both though with the package name as the only difference. The package name was dependent on the name of the root directory of respective client and server code repositories.
It seems to me like your service isn't registered with the gRPC server. Make sure the server [application] is calling RegisterGreeterServer:
Did you set the right environment variables when cross compiling?
https://github.com/golang/go/wiki/GoArm
It seems to me like your service isn't registered with the gRPC server. Make sure the server [application] is calling
RegisterGreeterServer:
@dfawley Service registration is fine. I added a print just after that line in the code and I could see the print later during the tests.
Did you set the right environment variables when cross compiling?
https://github.com/golang/go/wiki/GoArm
@menghanl I did not come across this link at all. I am able to build and run go programs on the Pi as usual and have been able to test a basic client server functionality using TCP sockets in Go. And this is not just about running/testing on Pi, I can see the same problem on my Linux PC as well when I run the server embedded in another application and run the client separately. I suspect it has to do with the .proto and the .pb.go files. If only there is some reference on the "error codes" and what they mean exactly that could come handy right now.
Service registration is fine. I added a print just after that line in the code and I could see the print later during the tests.
If you're adding prints, try adding one here:
https://github.com/grpc/grpc-go/blob/c26cd97e18ad26799c9233fd79889f69df3f742a/server.go#L1290
I'm pretty sure this is where the error is coming from. If so, there is something wrong with your service registration (either the generated code or your usage of it; maybe the server you're contacting isn't the same as the one you've registered the service on).
Service registration is fine. I added a print just after that line in the code and I could see the print later during the tests.
If you're adding prints, try adding one here:
https://github.com/grpc/grpc-go/blob/c26cd97e18ad26799c9233fd79889f69df3f742a/server.go#L1290
I'm pretty sure this is where the error is coming from. If so, there is something wrong with your service registration (either the generated code or your usage of it; maybe the server you're contacting isn't the same as the one you've registered the service on).
@dfawley You are right. I added a print statement at this place in server.go and I'm able to see it in the output log. You pointed out that it could be because of the generated code or its usage. Is there any approach to debug what could have gone wrong here?
Make sure the service name ("helloworld.Greeter") is correct on the Register function you're calling in the server (e.g. https://github.com/grpc/grpc-go/blob/c26cd97e18ad26799c9233fd79889f69df3f742a/examples/route_guide/routeguide/route_guide.pb.go#L581). And make sure the Register function is being called on the same gRPC server the client is connecting to.
You could also print s.m when the error is produced to see the list of registered services for that server.
Make sure the service name ("helloworld.Greeter") is correct on the
Registerfunction you're calling in the server (e.g.). And make sure the
Registerfunction is being called on the same gRPC server the client is connecting to.
You could also prints.mwhen the error is produced to see the list of registered services for that server.
@dfawley Thank you for your inputs so far. I could finally fix the issue! The problem was that the service name in the .pb.go file on the client side did not match with the service name in the .pb.go file on the server side. Reason being that these files were generated from their respective .proto files which had exactly the same content obviously, barring the package name which was derived from the root directory in which the respective .proto file resided. And, eventually, different package names in .proto files resulted in different package name and service name in the generated .pb.go file
To ensure that the .pb.go files on server and client match perfectly, I had to replicated the same package structure on the client side as I had on the server side so that in the .proto file the same package name could be used.
I'm sure there should be a best practice to be followed in such a case that I'm unaware of right now as the approach I took seemed rather inconvenient.
I'm sure there should be a best practice to be followed in such a case that I'm unaware of right now as the approach I took seemed rather inconvenient.
You should only have one copy of any .proto file, and, further, only one copy of the generated (.pb.go) files as well. This would prevent any similar mismatches in the future from being possible.
Most helpful comment
It seems to me like your service isn't registered with the gRPC server. Make sure the server [application] is calling
RegisterGreeterServer:https://github.com/grpc/grpc-go/blob/c26cd97e18ad26799c9233fd79889f69df3f742a/examples/helloworld/greeter_server/main.go#L52