def run(): channel = grpc.insecure_channel('localhost:50051') stub = hello_pb2_grpc.GreeterStub(channel) # reponse = stub.SayHello(hello_pb2.HelloRequest(name='you')) # print(reponse.message) reponse = stub.PlusTest(hello_pb2.PlusRequest(num1=1, num2=2)) print(reponse.result)
def run_Map(): with grpc.insecure_channel('localhost:50051') as channel: stub = hello_pb2_grpc.GreeterStub(channel) response = stub.MapSayHello(hello_pb2.HelloRequest(name='kkk')) print("WAC Greeter client received: ") print(response.dict_map)
def run(): # NOTE(gRPC Python Team): .close() is possible on a channel and should be # used in circumstances in which the with statement does not fit the needs # of the code. with grpc.insecure_channel('localhost:50051') as channel: stub = hello_pb2_grpc.GreeterStub(channel) response = stub.SayHello(hello_pb2.HelloRequest(name='python-world')) print("Greeter client received: " + response.message)
def run(): # connect grpc server channel = grpc.insecure_channel('localhost:8089') # send grpc stub = hello_pb2_grpc.GreeterStub(channel) response = stub.SayHello(hello_pb2.Request(name = 'cpx')) print("Greeter client received: " + response.message)
def run(): channel = grpc.insecure_channel('localhost:50051') stub = hello_pb2_grpc.GreeterStub(channel) request = hello_pb2.RequestInfo() request.mtype = hello_pb2.HEART request.heart.devid = "xxxx-xxxx" request.heart.ver = "xxx" response = stub.SayHello(request) print("Greeter client received: " + str(response.rcode))
def main() -> None: print('Connecting...') try: with grpc.insecure_channel('localhost:50051') as channel: stub = hello_pb2_grpc.GreeterStub(channel) request = hello_pb2.HelloRequest() request.name = 'John' print('Sending request...') response = stub.SayHello(request) print('Response received') print(response.response) except grpc.RpcError as error: print(error)
import os import logging import grpc import hello_pb2 import hello_pb2_grpc PROTO_PATH = "../protos/hello.proto" SERVER_HOST = os.getenv("HOST", "0.0.0.0") SERVER_PORT = os.getenv("PORT", "50051") SERVER_ADDRESS = f'{SERVER_HOST}:{SERVER_PORT}' with grpc.insecure_channel(SERVER_ADDRESS) as channel: stub = hello_pb2_grpc.GreeterStub(channel) response = stub.SayHello(hello_pb2.HelloRequest(name='SimpliRoute')) print("Response: " + response.message)
def run(): channel = grpc.insecure_channel('localhost:50052') stub = hello_pb2_grpc.GreeterStub(channel) response = stub.SayHello(hello_pb2.HelloRequest(name='you')) print("Greeter client received: " + response.message)
def client_stub(): import hello_pb2_grpc channel = grpc.insecure_channel('localhost:9094') stub = hello_pb2_grpc.GreeterStub(channel) return stub
def run(): with grpc.insecure_channel('localhost:50051') as channel: # create channel stub = hello_pb2_grpc.GreeterStub(channel) # create stub to call service methods response = stub.SayHello(hello_pb2.HelloRequest(name='cae')) # call service methods print("Greeter client received: " + response.message)
def run(): channel = grpc.insecure_channel('localhost:50051') stub = hello_pb2_grpc.GreeterStub(channel) response = stub.SayHello(hello_pb2.HelloRequest(name='nyan')) print('message', response.message)
def run_WAC(): with grpc.insecure_channel('localhost:50051') as channel: stub = hello_pb2_grpc.GreeterStub(channel) response = stub.WacSayHello(hello_pb2.HelloRequest(name='kkk'))
def run(): with grpc.insecure_channel("localhost:50051") as channel: stub = hello_pb2_grpc.GreeterStub(channel) response = stub.SayHello(hello_pb2.HelloRequest(name="kapil")) print(response.message)
def main(argv): channel = grpc.insecure_channel('localhost:50051') stub = hello_pb2_grpc.GreeterStub(channel) hello_req = hello_pb2.HelloRequest(name='gRPC world') hello_rsp = stub.SayHello(hello_req) print(hello_rsp.message)
def run(): # channel = grpc.insecure_channel('localhost:50051') channel = grpc.insecure_channel('192.168.1.24:50051') stub = hello_pb2_grpc.GreeterStub(channel) response = stub.SayHello(hello_pb2.HelloRequest(name='goodspeed')) print("Greeter client received: " + response.message)
def run(): with grpc.insecure_channel('localhost:50051') as channel: stub = hello_pb2_grpc.GreeterStub(channel) response = stub.SayHello(hello_pb2.HelloRequest(name='Quan Vu')) print("Hello client received: " + response.message)