grpc request without any request param

1.3k Views Asked by At

I have a grpc server with request of type:

service AbcService {
 rpc GetInfo(GetInfoRequest) returns (GetInfoResponse) {}
}

message GetInfoRequest {}
message GetInfoResponse {
  string hostname = 3;
}

And this is my client:

channel = grpc.insecure_channel('test.url:1025')
client = svc_pb2_grpc.AbcServiceStub(channel)

# get response
resp = client.GetInfo

I am facing issues with the client, since I am not able to get any response from it. grpcurl works simply fine using: grpcurl -plaintext test.url:1025 AbcService/GetInfo

Is resp = client.GetInfo the right way in client to invoke this call (which is not expecting any request parameter)?

1

There are 1 best solutions below

0
On BEST ANSWER

The "stub" encapsulates your server with a class, where the different API calls (requests/responses) are method calls.

So first of all: resp = client.GetInfo()

However, GetInfo expects an GetInfoRequest, so you need:

resp = client.GetInfo(GetInfoRequest())