grpcurl icon indicating copy to clipboard operation
grpcurl copied to clipboard

Not able to query grpc healthcheck endpoints using grpcurl

Open keshavnandan opened this issue 4 years ago • 3 comments
trafficstars

I created a gRPC service and added grpc healthcheck endpoints as per the gRPC Health Checking Protocol and I am getting the status as SERVING when using the grpc_health_probe command. However, when I am calling the healthcheck endpoints using grpcurl command, its not working.

➜  healthcheck git: ✗ grpcurl -v -plaintext -protoset ./healthcheck.protoset -d '{"service": "healthcheck"}' localhost:8080 healthcheck.HealthCheck/Check

Resolved method descriptor:
rpc Check ( .healthcheck.HealthCheckRequest ) returns ( .healthcheck.HealthCheckResponse );

Response headers received:
(empty)

Response trailers received:
content-type: application/grpc
Sent 1 request and received 0 responses
ERROR:
  Code: Unimplemented
  Message: method Check not implemented

Following is my proto file which has both Check and Watch methods

syntax = "proto3";
option go_package = "healthcheck/healthcheck";
package healthcheck;

message HealthParams {
  string service = 1;
}

message HealthCheckRequest {
  string service = 1;
}

message HealthCheckResponse {
  enum ServingStatus {
    UNKNOWN = 0;
    SERVING = 1;
    NOT_SERVING = 2;
    SERVICE_UNKNOWN = 3;  // Used only by the Watch method.
  }
  ServingStatus status = 1;
}

message Health {
  // The health status
  string status = 1;
}

service HealthCheck{
  rpc Get(HealthParams) returns (Health) {}
  rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
  rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
}

What's working is the following

➜  healthcheck git: ✗ grpc-health-probe -addr=localhost:8080
status: SERVING

keshavnandan avatar Jun 29 '21 18:06 keshavnandan

I am having a similar issue. I am running a gRPC API on localhost:50051 and when I try to do grpcurl localhost:50051 grpchealthv1.Health/Check I get Failed to dial target host "localhost:50051": dial tcp 127.0.0.1:50051: connect: connection refused. I am able to see the host via telnet and can connect and hit the endpoint using a Python client.

I am also using the gRPC Health Checking Protocol (just changed the package to be grpchealthv1). Any help on what I am doing wrong is greatly appreciated.

mdable2 avatar Jul 01 '21 15:07 mdable2

@keshavnandan, sorry, but grpcurl does not do anything special with health-checking. That call would just be a normal RPC. One thing I do note that is suspicious: the gRPC health-checking protocol uses a service named grpc.health.v1.Health, but you have provided a proto where the name is healthcheck.HealthCheck. Why the difference? If you've followed the directions at that other doc page, I think that means you are using a health check impl that is part of an official gRPC runtime, which means the problem is likely this name mismatch. Try again but use the actual proto for the health-check service?.

@mdable2, "connection refused" is a typical TCP connection error -- nothing magical about grpcurl in that respect. Are you sure the server was actually up and running when you tried that? I don't see how grpcurl could get that error and another program not, unless the server was not accepting connections when grpcurl was invoked (not up or not listening on socket).

jhump avatar Jul 21 '21 13:07 jhump