ginokent Blog
About RSS JA

Testing gRPC Connectivity with curl

Command

printf '\x00\x00\x00\x00\x00' |
  curl \
    -v -s --http2 \
    --data-binary @- \
    --output - \
    -H "Content-Type: application/grpc" \
    -H "TE: trailers" \
    "${GRPC_ENDPOINT:?}/grpc.health.v1.Health/Check" |
  hexdump -C 

Simply send an empty message to /grpc.health.v1.Health/Check.

Example

  • Request: 00 00 00 00 00
    • The first byte 00 is the compression flag (0 = uncompressed)
    • The next 4 bytes 00 00 00 00 represent the message length (0 bytes)
$ printf '\x00\x00\x00\x00\x00' | curl -v -s --http2 -H "Content-Type: application/grpc" -H "TE: trailers" --data-binary @- --output - "${GRPC_ENDPOINT:?}/grpc.health.v1.Health/Check" | hexdump -C 
... omitted ...
00000000  00 00 00 00 02 08 01                              |.......|
00000007
  • Response 00 00 00 00 02 08 01
    • The first 5 bytes 00 00 00 00 02
      • The first byte 00 is the compression flag (0 = uncompressed)
      • The next 4 bytes 00 00 00 02 represent the message length (2 bytes)
    • The remaining 2 bytes 08 01