diff --git a/python/xoscar/backends/core.py b/python/xoscar/backends/core.py index c8fb54f..040c276 100644 --- a/python/xoscar/backends/core.py +++ b/python/xoscar/backends/core.py @@ -58,14 +58,20 @@ def _listen_client(self, client: Client): async def get_client_via_type( self, router: Router, dest_address: str, client_type: Type[Client] ) -> Client: - client = await router.get_client_via_type( - dest_address, client_type, from_who=self - ) + try: + client = await router.get_client_via_type( + dest_address, client_type, from_who=self + ) + except ConnectionError: + raise ServerClosed(f"Remote server {dest_address} closed") self._listen_client(client) return client async def get_client(self, router: Router, dest_address: str) -> Client: - client = await router.get_client(dest_address, from_who=self) + try: + client = await router.get_client(dest_address, from_who=self) + except ConnectionError: + raise ServerClosed(f"Remote server {dest_address} closed") self._listen_client(client) return client