I have created a GRPC service and client. Service is working and hosted on port 5001 but the client is throwing GRPC error as Method not implemented.
Server
class CalculatorService(Calculator_pb2_grpc.CalculatorServicer):
def SquareRoot(self, request, context):
response = Calculator_pb2.Number()
response.value = Calculator.square_root(request.value)
return response
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
Calculator_pb2_grpc.add_CalculatorServicer_to_server(
Calculator_pb2_grpc.CalculatorServicer(),
server)
print('Starting Server on port 5001')
server.add_insecure_port('[::]:5001')
server.start()
print('Server Started')
server.wait_for_termination()
Client
channel = grpc.insecure_channel('localhost:5001')
number = Calculator_pb2.Number(value=16)
response = Calculator_pb2_grpc.CalculatorStub(channel).SquareRoot(number)
print(response.value)
Error
C:\Users\anshul_jain\.virtualenvs\pythonCalc-hTzam63Y\Scripts\python.exe C:/Projects/GRPC/pythonCalc/client.py
Traceback (most recent call last):
File "C:/Projects/GRPC/pythonCalc/client.py", line 8, in <module>
response = Calculator_pb2_grpc.CalculatorStub(channel).SquareRoot(number)
File "C:\Users\anshul_jain\.virtualenvs\pythonCalc-hTzam63Y\lib\site-packages\grpc\_channel.py", line 946, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "C:\Users\anshul_jain\.virtualenvs\pythonCalc-hTzam63Y\lib\site-packages\grpc\_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: _InactiveRpcError of RPC that terminated with:
status = StatusCode.UNIMPLEMENTED
details = "Method not implemented!"
debug_error_string = "{"created":"@1630568886.349000000","description":"Error received from
peer \u00109\u00cc\u008f\u00a8\u0001",
"file":"src/core/lib/surface/call.cc",
"file_line":1070,"grpc_message":"Method not implemented!","grpc_status":12}"
Process finished with exit code 1