This utility will basically let you create a binary format of a grpc request which you can use with curl.
If you send the binary to a destination gRPC server that accepts healthchecks for a given service name. You can take the response back and check to see if the service is running or not.
Ofcourse almost 99% of the time you’d “just use” the gRPC healthcheck stub but there are occasions where the caller may not have all that setup (eg a loadbalancer’s healthcheck system that supports just HTTP and not gRPDC)
Anyway, this is something that i just wrote up this morning based on some work here
# download the proto wget https://raw.githubusercontent.com/grpc/grpc/master/src/proto/grpc/health/v1/health.proto # compile the proto protoc --descriptor_set_out=health.pb health.proto # run the client and specify the serviceName you want to healtcheck $ go run grpc_hc_wireformat.go --serviceName echo.EchoServer Loading package v1 Registering MessageType: HealthCheckRequest Registering MessageType: HealthCheckResponse HealthCheckRequest: service:"echo.EchoServer" Encoded HealthCheckRequest using protoreflect 0a0f6563686f2e4563686f536572766572 wire encoded HealthCheckRequest: 00000000110a0f6563686f2e4563686f536572766572
The output is the wireencoded format of a specific healthcheck
You can then use that wire formatted message in curl and dump the output.
In the following, i’m using a cloud run grpc server i host that hosts that specific service and healthchecks.
$ echo -n '00000000110a0f6563686f2e4563686f536572766572' | xxd -r -p - frame.bin $ curl -s --raw -X POST \ --http2-prior-knowledge \ -H "Content-Type: application/grpc" \ -H "TE: trailers" \ --data-binary @frame.bin \ https://grpc-server-6w42z6vi3q-uc.a.run.app:443/grpc.health.v1.Health/Check -o resp.bin
You can take the response and decode it:
$ xxd -p resp.bin 00000000020801 $ echo -n "0801" | xxd -r -p | protoc --decode grpc.health.v1.HealthCheckResponse health.proto status: SERVING
The specific cloud run service will randomly (
10% of times) return an UNHEALTHY response so you can use that to test as well