Commit 654031e9 authored by Anael Beutot's avatar Anael Beutot
Browse files

RPC error handling during auth.

parent d5c96055
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -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
        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