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)?
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 anGetInfoRequest
, so you need:resp = client.GetInfo(GetInfoRequest())