Skip to content

Instantly share code, notes, and snippets.

@shiponcs
Last active June 15, 2023 06:43
Show Gist options
  • Save shiponcs/dad54bcf2683b14ea8fe2f51578d7a3f to your computer and use it in GitHub Desktop.
Save shiponcs/dad54bcf2683b14ea8fe2f51578d7a3f to your computer and use it in GitHub Desktop.
Test a gRPC server with grpcurl tool

grpcurl tool usages

I have a grpc server running at 0.0.0.0:50051. I'll show how you can use grpcurl to test it. Before that, install grpcurl (mybe using go).

  1. List services the server provides:
user@matin ~/o/g/examples ((v1.55.1))> grpcurl  -plaintext localhost:50051 list
grpc.health.v1.Health
grpc.reflection.v1alpha.ServerReflection
helloworld.Greeter
user@matin ~/o/g/examples ((v1.55.1))> 
  1. Describe
user@matin ~/o/g/examples ((v1.55.1))> grpcurl  -plaintext localhost:50051 describe helloworld.Greeter
helloworld.Greeter is a service:
service Greeter {
  rpc SayHello ( .helloworld.HelloRequest ) returns ( .helloworld.HelloReply );
  rpc SayHelloAgain ( .helloworld.HelloRequest ) returns ( .helloworld.HelloReply );
  rpc SayHelloStreamReply ( .helloworld.HelloRequest ) returns ( stream .helloworld.HelloReply );
}
user@appsCode ~/o/g/examples ((v1.55.1))> 
  1. Invoke a RPC
user@matin ~/o/g/examples ((v1.55.1))> grpcurl -plaintext -d '{"name": "matin"}'  localhost:50051 helloworld.Greeter.SayHello
{
  "message": "Hello matin"
}
user@matin ~/o/g/examples ((v1.55.1))> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment