diff --git a/telethon/network/mtprotosender.py b/telethon/network/mtprotosender.py index 556d0a7f..c2e1dc36 100644 --- a/telethon/network/mtprotosender.py +++ b/telethon/network/mtprotosender.py @@ -373,12 +373,12 @@ class MTProtoSender: # 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') + self.auth_key.key = None + if self._auth_key_callback: + self._auth_key_callback(None) 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 ' @@ -497,13 +497,12 @@ class MTProtoSender: except BufferError as e: if isinstance(e, InvalidBufferError) and e.code == 404: self._log.info('Broken authorization key; resetting') + self.auth_key.key = None + if self._auth_key_callback: + self._auth_key_callback(None) else: self._log.warning('Invalid buffer %s', e) - self.auth_key.key = None - if self._auth_key_callback: - self._auth_key_callback(None) - self._start_reconnect(e) return except Exception as e: