diff --git a/telethon/network/mtprotosender.py b/telethon/network/mtprotosender.py index 17c5e2e5..556d0a7f 100644 --- a/telethon/network/mtprotosender.py +++ b/telethon/network/mtprotosender.py @@ -369,6 +369,16 @@ class MTProtoSender: self._log.info('Failed reconnection attempt %d with %s', attempt, e.__class__.__name__) await asyncio.sleep(self._delay) + except BufferError as e: + # TODO there should probably only be one place to except all these errors + if isinstance(e, InvalidBufferError) and e.code == 404: + self._log.info('Broken authorization key; resetting') + else: + self._log.warning('Invalid buffer %s', e) + + self.auth_key.key = None + if self._auth_key_callback: + self._auth_key_callback(None) except Exception as e: last_error = e self._log.exception('Unexpected exception reconnecting on '