How to use grpcurl to test gRPC servers

gRPC is a high performance, open source universal RPC framework from Google. gRPC servers use a binary encoding on the wire (protocol buffers, or “protobufs” for short). So they are basically impossible to interact with using regular curl. grpcurl is a command-line tool that lets you interact with gRPC servers. It’s basically curl for gRPC servers.

How to use grpcurl tool to test gRPC server

First we need to have grpcurl installed in our system. Please follow this and make sure that you can access grpcurl from you command line.

Now, we run a sample gRPC server. You may find some sample gRPC servers on Github . I have a grpc server running at 0.0.0.0:50051. Let’s see how we can use grpcurl to test it. Please make sure that the gRPC server you running supports Reflection API service.

  1. List services the server provides:
> grpcurl  -plaintext localhost:50051 list
grpc.health.v1.Health
grpc.reflection.v1alpha.ServerReflection
helloworld.Greeter
  1. Describe any of those services
> 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 );
}
  1. Invoke a RPC
> grpcurl -plaintext -d '{"name": "matin"}'  localhost:50051 helloworld.Greeter.SayHello
{
  "message": "Hello matin"
}

TAGS

Get Up and Running Quickly

Deploy, manage, upgrade Kubernetes on any cloud and automate deployment, scaling, and management of containerized applications.