Updated wording in IPC client
This commit is contained in:
@@ -46,20 +46,20 @@ class IPCClient:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
msg = await self._websocket.receive()
|
msg = await self._websocket.receive()
|
||||||
self._logger.debug(f"Receive Message: {msg}")
|
self._logger.debug(f"Received Message: {msg}")
|
||||||
except:
|
except:
|
||||||
break
|
break
|
||||||
|
|
||||||
if msg.type in [aiohttp.WSMsgType.CLOSE, aiohttp.WSMsgType.CLOSED]:
|
if msg.type in [aiohttp.WSMsgType.CLOSE, aiohttp.WSMsgType.CLOSED]:
|
||||||
self._is_connected = False
|
self._is_connected = False
|
||||||
|
self._logger.info("Connection closed. Trying to reconnect in 10s.")
|
||||||
self._logger.info("Trying to reconnect dashboard in 10s")
|
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
|
|
||||||
if not self._is_connected:
|
if not self._is_connected:
|
||||||
try:
|
try:
|
||||||
await self.connect()
|
await self.connect()
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
self._logger.error("Reconnection failed.")
|
||||||
else:
|
else:
|
||||||
self._bot.loop.create_task(process_methods(self, self._bot, msg.json()))
|
self._bot.loop.create_task(process_methods(self, self._bot, msg.json()))
|
||||||
|
|
||||||
@@ -73,27 +73,27 @@ class IPCClient:
|
|||||||
if not self._session:
|
if not self._session:
|
||||||
self._session = aiohttp.ClientSession()
|
self._session = aiohttp.ClientSession()
|
||||||
|
|
||||||
if self._is_connecting:
|
if self._is_connecting or self._is_connected:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._is_connecting = True
|
self._is_connecting = True
|
||||||
self._websocket = await self._session.ws_connect(
|
self._websocket = await self._session.ws_connect(
|
||||||
self._websocket_url, headers=self._heanders, heartbeat=self._heartbeat
|
self._websocket_url, headers=self._heanders, heartbeat=self._heartbeat
|
||||||
)
|
)
|
||||||
|
|
||||||
self._task = self._bot.loop.create_task(self._listen())
|
self._task = self._bot.loop.create_task(self._listen())
|
||||||
self._is_connected = True
|
self._is_connected = True
|
||||||
|
|
||||||
self._logger.info("Connected to dashboard!")
|
self._logger.info("Connected to dashboard!")
|
||||||
|
|
||||||
except aiohttp.ClientConnectorError:
|
except aiohttp.ClientConnectorError:
|
||||||
raise Exception("The connection is failed.")
|
raise Exception("Connection failed.")
|
||||||
|
|
||||||
except aiohttp.WSServerHandshakeError:
|
except aiohttp.WSServerHandshakeError as e:
|
||||||
raise Exception("The password is invalid.")
|
self._logger.error("Access forbidden: Missing bot ID, version mismatch, or invalid password.")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error("Error occured while connecting to dashboard!", exc_info=e)
|
self._logger.error("Error occurred while connecting to dashboard.", exc_info=e)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
self._is_connecting = False
|
self._is_connecting = False
|
||||||
|
|||||||
Reference in New Issue
Block a user