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
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/4ce6fa34-b5a5-49d0-9296-b6c25cdc33ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.