Skip to content

gRPC probe

The gRPC probe calls a method on a gRPC server and records the call with everything that was sent and everything that came back. VirtuProbe speaks gRPC directly: its HTTP/2, HPACK and protobuf are written against the specification rather than wrapped around a gRPC library, so you can send what a library would refuse (a message that is not valid protobuf, a frame whose stated length does not match its payload, a call made with no schema at all) and see what the server did with it.

A probe is a connection, an identity, a call type, the service and method, where the schema comes from and the messages to send. One send opens the HTTP/2 connection, makes the call and reads it to the end.

The gRPC probe editor: a plaintext HTTP/2 connection to localhost on port 50051, the schema taken from server reflection and a unary call to demo.v1.Echo Say carrying a JSON request message.

FieldDescription
HostThe address of the server (default: localhost)
PortThe port the server listens on (default: 50051)
TLS modeNone for plaintext HTTP/2, TLS for HTTP/2 over TLS
Trust self-signed certificatesAccept a server certificate that does not verify. Shown with TLS on. Lab use

Over TLS the client offers h2 in the ALPN handshake. If the server negotiates something else, HTTP/2 is spoken anyway and the result records a note saying so.

gRPC carries authentication as request metadata, not as an HTTP authentication scheme. Pick a Credential from the credential store. The secret never lives on the probe: it holds the credential id or an {{name}} environment binding the probe resolves on send.

The schemes a single piece of metadata can carry are the ones offered: a Bearer token, an API key placed under a metadata key, Basic, an OAuth2 token and a set of raw metadata headers. A credential of any other scheme is not offered, because it could not be sent as metadata and would read as a refusal by the server. New credential makes a Bearer, API key or Basic credential without leaving the editor.

A probe with no credential of its own sends with the project default, the way it would in a chain. A probe that names its own credential uses that.

Pick a Call type. It decides what the rest of the editor asks for.

Call typeWhat it does
UnaryOne request message, one response message
Server streamingOne request message. The server answers with a stream of messages
Client streamingA stream of request messages, sent in order. The server answers once
Bidirectional streamingBoth sides stream. Every message is sent, then the answers are read to the end
Health checkCalls grpc.health.v1.Health/Check. Passes when the answer is SERVING
Health watchCalls grpc.health.v1.Health/Watch, which never ends by itself. Set a stop-after count
List servicesAsks server reflection for the services the server exposes
Describe a symbolAsks server reflection for a service, method, message or enum and prints its schema
Raw HTTP/2 framesSends HTTP/2 frames exactly as written and reports what the server does. Nothing is checked or corrected

Authority is the :authority the call sends. Left empty, it is host:port.

For a call to a method you give the Service with its package (grpc.health.v1.Health) and the Method.

A gRPC request is protobuf, so writing a message as JSON needs the message type. Schema from decides where that comes from.

SourceWhat it needs
Server reflectionNothing. The schema is asked from the server when the probe runs
.proto sourceThe .proto source pasted in. The first file is compiled. Imports of google/protobuf files are built in
Descriptor setA FileDescriptorSet as base64, such as protoc writes with descriptor_set_out
No schemaNothing. Messages are sent as hex and answers are shown by field number

Load schema reads the schema from where the probe names, contacting the target when the source is reflection. It fills the service and method lists with what it found. Picking a method then sets the call type from the schema and seeds a request to start from. A source that comes back with nothing is a note on the result rather than a failure: a call whose messages are all hex does not need a schema.

Each message has a Format and a body.

  • JSON is the ProtoJSON form of the method’s input type and needs a schema. The Template button fills it with every field of the type and a placeholder value.
  • HEX is the message octets exactly as sent. It works without a schema and can be any octets at all, which is how you send a body a conforming client would never build.

A client or bidirectional streaming call shows a Delay, ms per message, the wait before that message is sent. Every message is encoded before anything goes out, so a mistake in the third message does not leave the server holding the first two. A call with no messages sends an empty request stream.

Metadata adds custom entries to the call, each a name and a value sent as a request header.

Three options sit below the call:

OptionDescription
Deadline, msSent as grpc-timeout and kept locally. 0 sends none
CompressionThe grpc-encoding to compress request messages with: gzip or deflate. None leaves them uncompressed
Stop after messagesStop reading a stream after this many messages and cancel the call. 0 reads to the end. Shown for a server or bidirectional stream and for health watch

Raw HTTP/2 frames sends frames one by one after the connection preface and reads for a while after each. Nothing is judged: the frames go out as written and the server’s reaction is reported.

FieldDescription
TypeThe frame type: DATA, HEADERS, SETTINGS and the rest of RFC 9113
FlagsThe flags octet, 0 to 255
StreamThe stream id
Payload, hexThe payload. Spaces are ignored
Stated lengthThe length to write in the frame header. Left empty it is the real payload length, so set it to state a length the payload does not match
Wait, msHow long to read after this frame before sending the next

The result names the transport outcome, the HTTP :status, the grpc-status with its name and number, the grpc-message and how the call ended (with trailers, reset, a GOAWAY, a closed connection, canceled, a passed deadline or without trailers). It flags a trailers-only response and a status it had to assume because the server sent none.

A gRPC response: grpc-status 0 OK, the reply message decoded as JSON and by protobuf field number with its hex, over panels for the sent messages, the request and response headers, the trailers and the HTTP/2 frames.

Each response message is shown as JSON where there is a schema, by field number and as hex. The sent messages, the request headers (with secrets masked), the response headers and the trailers are all there. So are the HTTP/2 frames of the exchange in both directions.

Anything the server did that broke HTTP/2 or the specification without ending the call is listed separately, for example a GOAWAY or an out-of-line frame.

A call counts as a pass when it ends cleanly with grpc-status 0. A stream the probe cut short on purpose passes when it got the messages it asked for. A health check passes only on SERVING.

An expression on the message extractors may start with a message index and a colon, such as 2:user.name. Without one the last message is meant, which for a unary call is the only one.

ExtractorReturns
GRPC_SUCCESStrue when the probe passed, otherwise false
GRPC_STATUS_CODEThe grpc-status number. Blank when the probe made no call
GRPC_STATUS_NAMEThe name of the grpc-status, such as NOT_FOUND
GRPC_STATUS_MESSAGEThe grpc-message, percent-decoded
GRPC_HTTP_STATUSThe HTTP :status. Blank when no response headers arrived
GRPC_TRANSPORT_OUTCOMEHow the conversation ended, such as OK, RST or CONNECT_REFUSED
GRPC_MESSAGE_COUNTHow many response messages arrived
GRPC_MESSAGEOne response message as JSON (or as hex where there is no schema). An index picks the message; blank is the last
GRPC_MESSAGE_FIELDA value inside a response message by its JSON path, such as user.emails[0]
GRPC_MESSAGE_RAW_FIELDA value by a path of field numbers, such as 1.3[0].2, which needs no schema
GRPC_SERVICESThe service names a reflection listing returned, one per line
GRPC_HEADERA response header by name
GRPC_TRAILERA response trailer by name

gRPC is a chain step. {{variable}} placeholders resolve into the host, the authority, the service and method, the health service, the symbol, every metadata value, every message body and every raw frame payload before the probe is sent. The port is a number and is not a place for a variable. Credentials are never inline in a chain: they resolve on the server from the credential store.

One pattern is a unary call, then GRPC_MESSAGE_FIELD to pull a value out of the reply and an assert on it. Another is List services followed by Describe a symbol on a name the first step returned.

gRPC is HTTP/2 and the client speaks first with the fixed HTTP/2 connection preface, which is how the proxy recognizes it. Over TLS the client offers h2 in ALPN and the proxy accepts it.

A mock rule for gRPC matches on the host and on the method path, the /package.Service/Method the call carries. The host is matched whole without case, the method path as a substring without case, so a rule for Greeter/SayHello answers /helloworld.Greeter/SayHello. A blank field matches anything.

A MOCK reply is the response the server would have sent: a sequence of response messages, one protobuf hex block per line (each without the five-octet gRPC length prefix, which is added for you) and a final gRPC status with an optional status message. One message covers a unary reply and several cover a stream. A status of 0 with messages is a normal reply. A non-zero status with no message is an error returned as trailers only. A rule can be drafted from a captured call.

A rule set marked to apply to outgoing traffic stands in for the backend on a direct probe, chain or script send, so the target is never contacted. Only a call addressed by a method path can be mocked this way. A reflection or raw-frame call has no method path, so it falls through to the real send.

  • VirtuProbe is the client. The probe calls a server. It does not stand up a gRPC server for something else to call.
  • The probe speaks gRPC over HTTP/2, the standard transport.
  • The credential schemes above are the ones that can be sent as gRPC metadata.

A probe file written by hand or over MCP is shaped like this.

  • The call type field is callType: UNARY, SERVER_STREAMING, CLIENT_STREAMING, BIDI_STREAMING, HEALTH_CHECK, HEALTH_WATCH, REFLECTION_LIST_SERVICES, REFLECTION_DESCRIBE or RAW_FRAMES.
  • The schema field is schemaSource: REFLECTION, PROTO, DESCRIPTOR_SET or NONE.
  • The TLS field is tlsMode, with NONE or TLS. It is not called sslMode.
  • A message is {"enabled": true, "format": "JSON", "body": "{}", "delayMs": 0}. Set format to HEX to send octets as they are.
  • The editor’s Stop after messages is maxResponseMessages. A second field, cancelAfterMessages, set only by hand, cuts the call off with an RST_STREAM once that many response messages have arrived.
  • A raw frame’s type, flags and declaredLength each take any value in range (type and flags any octet from 0 to 255), so a hand-written frame is not held to the frame types the editor lists.