I want to send a class to the grpc server. So, I am pickling the class and
sharing as a bytes format in the message.
The .proto file(serverdata.proto) looks like below:
syntax = "proto3";
service DataProvider{
rpc Get_Data(client_class) returns (result);
}
message client_class{
bytes class_str = 1;
}
message result{
int64 res = 1;
}
client.py file looks like below:
import grpc
import serverdata_pb2
import serverdata_pb2_grpc
import pickle
import pandas as pd
class Get_Hash():
def get_hash(self,df):
return pd.util.hash_pandas_object(df).sum()
a = serverdata_pb2.client_class()
a.class_str = pickle.dumps(Get_Hash)
channel = grpc.insecure_channel('localhost:50051')
# create a stub (client)
stub = serverdata_pb2_grpc.DataProviderStub(channel)
response = stub.Get_Data(a)
print(response.res)
On running this client, I'm getting the following error:
Traceback (most recent call last):
File "client.py", line 18, in <module>
response = stub.Get_Data(a)
File "/home/jatin/.local/lib/python3.8/site-packages/grpc/_channel.py",
line 826, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/home/jatin/.local/lib/python3.8/site-packages/grpc/_channel.py",
line 729, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated
with:
status = StatusCode.UNKNOWN
details = "Exception calling application: client_class"
debug_error_string =
"{"created":"@1600867086.557068214","description":"Error received from peer
ipv6:[::1]:50051","file":"src/core/lib/surface/call.cc","file_line":1061,"grpc_message":"Exception
calling application: client_class","grpc_status":2}"
>
I'm unable to resolve this error. I checked the type of the pickle file. It
was 'bytes'. So, I changed the type in the .proto file to bytes. I'd be
grateful if someone can help me resolve this error.
Regards,
Jatin
--
You received this message because you are subscribed to the Google Groups
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/6d5abb5a-a16e-4b11-9a1d-2532b299cdcbn%40googlegroups.com.