rajan sthapit
rajan sthapit

Reputation: 4354

Not able to connect to go grpc server using python client

I have a grpc server running in Go. I am not able to call a method into it using the python client. Not sure what is going wrong. I get the following error

_Rendezvous of RPC that terminated with (StatusCode.UNIMPLEMENTED, method: /com.test/myMethod)>

Any idea what could have gone wrong? The Go client is able to communicate properly.

Also I generated the stubs following the instructions https://grpc.io/docs/tutorials/basic/python.html

python -m grpc_tools.protoc -I../../protos --python_out=. --grpc_python_out=. ../../protos/route_guide.proto

Once I got the py files, I removed the proto files and zipped the package. This zipped package is what I am using for my python client. Is there anything wrong?

Upvotes: 0

Views: 4433

Answers (4)

Skrypko Dzmitry
Skrypko Dzmitry

Reputation: 1

Check that your proto-file in Python-client is equal to the proto-file in Go-server. It is crucial.

The Go allows skipping the description of unused RPC calls and messages in proto-file, while Python requires all of them.

Upvotes: 0

I had tried to reproduce your issue and found that:

The names of class that we implement in server.py and the class we add to the gRPC server must be the same.

Example:

class SubClassImplemented(ExtendedClassGenerated):
    ...

def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    add_<name>_to_server(SubClassImplemented(), server)

Here,

SubClassImplemented - the class inherits from the generated class, must be added to the gRPC server.

ExtendedClassGenerated - generated class present in <name>_pb2_grpc.py

add_<name>_to_server() - method present in <name>_pb2_grpc.py, used to add your logic to a gRPC server.

Hope this helps!! I've also added a screenshot for the same.

add server class to gRPC server screenshot

Upvotes: 0

SixenseMan
SixenseMan

Reputation: 155

I ran into a similar issue, I changed the port number on the server and client side and then everything worked fine.

server.add_insecure_port('[::]:50053')

changing 50051 to 50053 is what worked for me.

Upvotes: -3

Pierluigi
Pierluigi

Reputation: 33

Sometimes I get StatusCode.UNIMPLEMENTED when the version of the protocol buffer files used by the client and the by server are in a inconsistent status.

For example I made a change in the proto buffer file in the server but I forgot to change the proto buffer file in the client.

I don't know if this can help but sometime it happened to me.

Upvotes: 3

Related Questions