没有任何请求参数的 grpc 请求
grpc request without any request param
我有一个 grpc 服务器,请求类型为:
service AbcService {
rpc GetInfo(GetInfoRequest) returns (GetInfoResponse) {}
}
message GetInfoRequest {}
message GetInfoResponse {
string hostname = 3;
}
这是我的客户:
channel = grpc.insecure_channel('test.url:1025')
client = svc_pb2_grpc.AbcServiceStub(channel)
# get response
resp = client.GetInfo
我遇到了客户端问题,因为我无法从它那里得到任何响应。 grpcurl
使用:
grpcurl -plaintext test.url:1025 AbcService/GetInfo
resp = client.GetInfo
是客户端调用此调用的正确方法吗(不需要任何请求参数)?
“存根”用 class 封装您的服务器,其中不同的 API 调用 (requests/responses) 是方法调用。
所以首先:
resp = client.GetInfo()
但是,GetInfo
需要 GetInfoRequest
,因此您需要:
resp = client.GetInfo(GetInfoRequest())
我有一个 grpc 服务器,请求类型为:
service AbcService {
rpc GetInfo(GetInfoRequest) returns (GetInfoResponse) {}
}
message GetInfoRequest {}
message GetInfoResponse {
string hostname = 3;
}
这是我的客户:
channel = grpc.insecure_channel('test.url:1025')
client = svc_pb2_grpc.AbcServiceStub(channel)
# get response
resp = client.GetInfo
我遇到了客户端问题,因为我无法从它那里得到任何响应。 grpcurl
使用:
grpcurl -plaintext test.url:1025 AbcService/GetInfo
resp = client.GetInfo
是客户端调用此调用的正确方法吗(不需要任何请求参数)?
“存根”用 class 封装您的服务器,其中不同的 API 调用 (requests/responses) 是方法调用。
所以首先:
resp = client.GetInfo()
但是,GetInfo
需要 GetInfoRequest
,因此您需要:
resp = client.GetInfo(GetInfoRequest())