Skip to content

Commit

Permalink
Add quick 5 retries when connecting to Telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Nov 13, 2023
1 parent 2a67c96 commit d47fb1d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mautrix_telegram/abstract_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,16 @@ async def has_full_access(self, allow_bot: bool = False) -> bool:
async def start(self, delete_unless_authenticated: bool = False) -> AbstractUser:
if not self.client:
await self._init_client()
await self.client.connect()
while True:
attempts = 1
try:
await self.client.connect()
except Exception:
self.log.exception("Exception connecting to Telegram, retrying in 5s...")
attempts += 1
if attempts > 10:
raise
await asyncio.sleep(5)
self.log.debug(f"{'Bot' if self.is_relaybot else self.mxid} connected: {self.connected}")
return self

Expand Down

0 comments on commit d47fb1d

Please sign in to comment.