0
Amazon EC2 인스턴스에서 gRPC 서버/클라이언트를 빌드 할 때 문제가 발생했습니다.Amazon EC2에서 gRPC 서버 구축
인스턴스 A (개인 IP : 예 : 1.2.3.4)가 있습니다. 한편
from concurrent import futures
import time
import math
import grpc
import helloworld_pb2
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
class Greeter(helloworld_pb2.GreeterServicer):
def SayHello(self, request, context):
return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
helloworld_pb2.add_GreeterServicer_to_server(Greeter(), server)
server.add_insecure_port('1.2.3.4:50051')
server.start()
try:
while True:
time.sleep(_ONE_DAY_IN_SECONDS)
except KeyboardInterrupt:
server.stop(0)
if __name__ == '__main__':
serve()
는, 인스턴스 B는 사설 IP 2.3.4.5을 가지고 같은 서버 코드는, 나는 그것을
from __future__ import print_function
import grpc
import helloworld_pb2
def run():
channel = grpc.insecure_channel('1.2.3.4:50051')
stub = helloworld_pb2.GreeterStub(channel)
response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
print("Greeter client received: " + response.message)
if __name__ == '__main__':
run()
클라이언트와 서버 코드를 실행에 클라이언트 스크립트를 실행하고 싶습니다 잘 로컬 컴퓨터에서. 내가 EC2 클러스터에서이를 실행하려고 할 때, 클라이언트는 서버
Traceback (most recent call last):
File "helloworld_client.py", line 47, in <module>
run()
File "helloworld_client.py", line 42, in run
response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
File "/usr/local/lib/python3.4/dist-packages/grpc/_channel.py", line 481, in __call__
return _end_unary_response_blocking(state, False, deadline)
File "/usr/local/lib/python3.4/dist-packages/grpc/_channel.py", line 432, in _end_unary_response_blocking
raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE,)>
을 찾는데 실패 스크립트가 실행 얻을 어떻게해야합니까?
감사합니다.