Search code examples
c#postmangrpc

How can you setup GRPC so you can test the HealthCheck from Postman?


I'm new to gRPC and have been reading about Health Checks to ensure the server is up and ready to receive requests. To that end I've got this in the server Program.cs:

services.AddGrpc();
services.AddGrpcHealthChecks().AddCheck("Check", () => HealthCheckResult.Healthy());
services.Configure<HealthCheckPublisherOptions>(options => options.Delay = TimeSpan.Zero);

For the app builder I add this:

app.UseRouting();
app.UseGrpcWeb(new GrpcWebOptions { DefaultEnabled = true });
app.UseEndpoints(endpoints =>
{
    endpoints.MapGrpcHealthChecksService();
    endpoints.MapGet("/", () => "Some text");
});

I assume that this is effectively adding a default Health Check service that can be called. I can see how a client would call it, by setting up a channel and using the url, but how could you call this from Postman? The gRPC request requires a protobuf file (which there isn't 1), server reflection to be enabled (which it's not) or to create and use a protobuf api.

Update

I've tried creating a proto file that should meet the requirements of the service from here and it seems to match what I see is setup in the app builder in that they both reference grpc.health.v1.health/Check. However, when invoking it from postman I get this error:

"Received RST_STREAM with code 2 triggered by internal client error: Protocol error"


Solution

  • Looks like this is a protocol problem. I need to configure that correctly before postman was able to connect.