2
필자는 Python gRPC 서버를 Heroku에 배포했으며 어떻게 로컬 Python 클라이언트로 테스트 할 수 있는지 궁금해하고있었습니다.heroku에 gRPC 서버/클라이언트를 배포하는 방법은 무엇입니까?
server.py 내 컴퓨터에서 클라이언트를 사용하고 서버에서 모든 응답을 수신하지 못하는 경우
def run():
# Is the channel url correct?
channel = grpc.insecure_channel('https://www.HEROKUURL.com:50051')
stub = my_grpc.MyStub(channel)
file = _get_file_content()
response = stub.Predict(icp_pb2.MyRequest(file_content=file))
print("received: " + response.results)
def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
icp_pb2_grpc.add_MyServicer_to_server(MyServicer(), server)
server_port = os.environ.get('PORT', 50051)
server.add_insecure_port('[::]:'+ str(server_port))
server.start()
print("==== SERVER RUNNING =====")
try:
while True:
time.sleep(_ONE_DAY_IN_SECONDS)
except KeyboardInterrupt:
server.stop(0)
if __name__ == '__main__':
serve()
client.py. 로컬로 실행되면 서버와 성공적으로 통신 할 수 있습니다. 내가 도대체 뭘 잘못하고있는 겁니까?
gRPC가 문제에 얼마나 관련되어 있습니까? Heroku 환경에서 일반 HTTP 서버를 실행하고 서버에 연결할 수 있습니까? –
@ NathanielManistaAtGoogle 확실히, 나는 일반 서버와 성공적으로 통신 할 수있었습니다. gRPC 응용 프로그램도 완벽하게 로컬로 작업하고있었습니다. gRPC에 문제가있는 것은 아닙니다. 단지 배포하고 서버에 연결하는 방법을 정확히 모르겠습니다. – 4d11