diff --git a/ccnode/node.py b/ccnode/node.py index f4e327293b167934d175b95edd59c25c1b38b5f7..31c9a9d74e476ea99929f13f13fc026d2c395e52 100644 --- a/ccnode/node.py +++ b/ccnode/node.py @@ -7,7 +7,7 @@ from collections import defaultdict from functools import partial import pyev -from sjrpc.core import RpcConnection +from sjrpc.core import RpcConnection, RpcError from sjrpc.utils import ConnectionProxy, RpcHandler, threadless from ccnode import __version__ @@ -106,12 +106,21 @@ class RPCStartHandler(Thread): return # try to authenticate - self.auth_id = self.rpc_con.rpc.async_call_cb( - self.auth_done_cb, - 'authentify', - self.loop.config.server_user, - self.loop.config.server_passwd, - ) + try: + self.auth_id = self.rpc_con.rpc.async_call_cb( + self.auth_done_cb, + 'authentify', + self.loop.config.server_user, + self.loop.config.server_passwd, + ) + except RpcError as exc: + if exc.exception == 'RpcConnectionError': + logger.error('Authentication failed: connection lost') + else: + logger.exception('Unexpected exception while authenticating') + + self.stop() + self.loop.restart_rpc_connection() def auth_done_cb(self, call_id, response=None, error=None): assert call_id == self.auth_id