def iniciar(self):
     server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
     grpc_chat.add_ChatAdminServicer_to_server(self, server)
     print('Iniciando server. Escuchando en puerto 50051.')
     server.add_insecure_port('[::]:50051')
     server.start()
     server.wait_for_termination()
Example #2
0
 def iniciar(self):
     server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
     grpc_chat.add_ChatAdminServicer_to_server(Servidor(), server)
     print('Iniciando server. Escuchando en puerto 50051.')
     server.add_insecure_port('[::]:50051')
     server.start()
     try:
         while True:
             time.sleep(10000)
     except KeyboardInterrupt:
         server.stop(0)
Example #3
0
 def iniciar(self):
     print('Iniciando server. Escuchando en puerto 50051.')
     with open('server.key', 'rb') as f:
         private_key = f.read()
     with open('server.crt', 'rb') as f:
         certificate_chain = f.read()
     with open('rootCA.crt', 'rb') as f:
         ca_cert = f.read()
     server_credentials = grpc.ssl_server_credentials(
         [(private_key, certificate_chain)],
         root_certificates=ca_cert,
         require_client_auth=False)
     server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
     grpc_chat.add_ChatAdminServicer_to_server(self, server)
     server.add_secure_port('159.89.50.94:50051', server_credentials)
     server.start()
     try:
         while True:
             time.sleep(10000)
     except KeyboardInterrupt:
         server.stop(0)