Skip to content
Snippets Groups Projects
Commit 654031e9 authored by Anael Beutot's avatar Anael Beutot
Browse files

RPC error handling during auth.

parent d5c96055
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment