Only reset auth_key on error -404

This error is "auth key not found", and the authorization key should
probably not be reset on other error codes. This might address #1457.
This commit is contained in:
Lonami Exo 2020-10-05 14:08:21 +02:00
parent 185a93a105
commit 09f4c5c708

View File

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