diff --git a/bitbake/lib/bb/asyncrpc/client.py b/bitbake/lib/bb/asyncrpc/client.py index 9be49261c0..17b72033b9 100644 --- a/bitbake/lib/bb/asyncrpc/client.py +++ b/bitbake/lib/bb/asyncrpc/client.py @@ -112,11 +112,16 @@ class AsyncClient(object): ) async def connect_sock(): - websocket = await websockets.connect( - uri, - ping_interval=None, - open_timeout=self.timeout, - ) + try: + websocket = await websockets.connect( + uri, + ping_interval=None, + open_timeout=self.timeout, + ) + except asyncio.exceptions.TimeoutError: + raise ConnectionError("Timeout while connecting to websocket") + except (OSError, websockets.InvalidHandshake, websockets.InvalidURI) as exc: + raise ConnectionError(f"Could not connect to websocket: {exc}") from exc return WebsocketConnection(websocket, self.timeout) self._connect_sock = connect_sock