Expect BufferError during automatic reconnect

This seems to occur whe the Telegram servers are dying and logging
everyone out.
This commit is contained in:
Lonami Exo 2020-10-05 14:07:11 +02:00
parent 20606b3a71
commit 185a93a105

View File

@ -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 '