Hi,
we are trying to use gRPC in the following configuration:
- a test_runner the initiate both client and server
- once up, client and server should exchange messages in a bidirectional way
- with the server that start to send messages
- at the end of the tests both client and server are shutting down
Is it possible to create something similar with gRPC?
I saw something similar in this paper http://platformlab.stanford.edu/Seminar%20Talks/gRPC.pdf
We are using python, is there any example or documentation to explain how to do if it is possible? (also in another languages is fine).
Thanks
we are trying to use gRPC in the following configuration:
- a test_runner the initiate both client and server
- once up, client and server should exchange messages in a bidirectional way
- with the server that start to send messages
- at the end of the tests both client and server are shutting down
Is it possible to create something similar with gRPC?
I saw something similar in this paper http://platformlab.stanford.edu/Seminar%20Talks/gRPC.pdf
We are using python, is there any example or documentation to explain how to do if it is possible?
(also in another languages is fine).
Hi Nathaniel,
yes I upgraded to latest python version of grpc (1.0.0rc1) but in all the examples that I checked the scenario is the following:
- start server
- start client
- client send message to server that reply (https://github.com/grpc/grpc/blob/846768c12ff03ea69073c9373ef211ef478c53d6/examples/python/helloworld/greeter_client.py#L42)
I need to create a scenario where is the server that send message to client once both are up and running (as first that initiate the communication).
Maybe I'm missing something in the example/documentation, could you please point me where to look?
Thanks
yes I upgraded to latest python version of grpc (1.0.0rc1) but in all the examples that I checked the scenario is the following:
- start server
- start client
- client send message to server that reply (https://github.com/grpc/grpc/blob/846768c12ff03ea69073c9373ef211ef478c53d6/examples/python/helloworld/greeter_client.py#L42)
I need to create a scenario where is the server that send message to client once both are up and running (as first that initiate the communication).
Maybe I'm missing something in the example/documentation, could you please point me where to look?
Hi, so do you suggest to do this:
client.py
import grpc
import generated.bidirectional_pb2 as bid
def
run():
channel = grpc.insecure_channel('localhost:50051')
stub
= bid.SpeakStub(channel)
if __name__ ==
'__main__':
run()
server.py
def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
bid.add_SpeakServicer_to_server(bid.SpeakServicer(),server)
server.add_insecure_port('[::]:50051')
server.start()
print "[SERVER] start at 50051"
try:
while True:
time.sleep(_ONE_DAY_IN_SECONDS)
except KeyboardInterrupt:
server.stop(0)
if __name__ == '__main__':
serve()
but I don’t get where I should implement the servicer SpeakServicer(bid.BetaSpeakServicer) and how to invoke it for be that the server send the message to the client.
Where the proto file is
service Speak {
rpc Message(stream Request) returns (stream Response){}
}
Can you help me?
Thanks
From:
Nathaniel Manista <nath...@google.com>
Date: Thursday, July 28, 2016 at 9:43 PM
To: "Mosca, Federico" <federic...@here.com>
Cc: "grp...@googlegroups.com" <grp...@googlegroups.com>
Subject: Re: [grpc-io] gRPC - server client communication
On Thu, Jul 28, 2016 at 12:15 PM, Mosca, Federico <federic...@here.com> wrote:
Hi, so do you suggest to do this:
client.py
import grpc
import generated.bidirectional_pb2 as bid
def run():
channel = grpc.insecure_channel('localhost:50051')
stub = bid.SpeakStub(channel)
if __name__ == '__main__':
run()
server.py
def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
bid.add_SpeakServicer_to_server(bid.SpeakServicer(),server)
server.add_insecure_port('[::]:50051')
server.start()
print "[SERVER] start at 50051"
try:
while True:
time.sleep(_ONE_DAY_IN_SECONDS)
except KeyboardInterrupt:
server.stop(0)
if __name__ == '__main__':
serve()
but I don’t get where I should implement the servicer SpeakServicer(bid.BetaSpeakServicer) and how to invoke it for be that the server send the message to the client.
Where the proto file is
service Speak {
rpc Message(stream Request) returns (stream Response){}
}Can you help me?
What is not so clear is if after the client call stub.message the server only 'reply' to that using the stream response and nothing else, is it correct?
Sever can not start a new exchanges of request/response to the client, right?
What we would like to do is:-client invoke the rpc (there is no other way I understood)-server ask something to the client-client do something somewhere else and return result to the serverIs it doable?