Hello,
I am making a communication between my Scala gRPC client and python gRPC server. My issue is when I make a blocking call from scala client, my request is handled. But in case of asynchronous stub, the request is not delivered at all. Can anyone help me out with this?.
Python gRPC server code
from gRPC2 import message_pb2, message_pb2_grpc
import grpc
from concurrent import futures
import time
class HandlerServicer(message_pb2_grpc.HandlerServicer):
def request_handler(self, request, context):
print('Received request:', request, request.request_message)
response = 'Reponse'
time.sleep(10)
return message_pb2.Response(response_message=response)
handler_server = grpc.server(futures.ThreadPoolExecutor())
message_pb2_grpc.add_HandlerServicer_to_server(HandlerServicer(), handler_server)
handler_server.add_insecure_port("[::]:{}".format(5000))
print('Starting server...')
handler_server.start()
try:
while True:
time.sleep(60*60*60)
except KeyboardInterrupt:
print('Stopping server...')
handler_server.stop(0)
Scala gRPC client code:
import io.grpc.ManagedChannelBuilder
import message._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext
object HandlerClient extends App {
val channel = ManagedChannelBuilder.forAddress("localhost", 5000).usePlaintext().build()
val request = Request("Request")
implicit val ec = ExecutionContext.global
// Making a Async call
val stub = HandlerGrpc.stub(channel)
val future = stub.requestHandler(request)
future onComplete println
}
Proto file:
syntax = "proto3";
service Handler{
rpc request_handler(Request) returns (Response){}
}
message Request{
string request_message = 1;
}
message Response{
string response_message = 1;
}
Thanks,
S Sathish Babu