mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-26 09:14:31 +03:00
Don't try to reconnect when authkey is invalid
This commit is contained in:
parent
5722ba8306
commit
026c992395
|
@ -338,7 +338,7 @@ class MTProtoSender:
|
||||||
"""
|
"""
|
||||||
Cleanly disconnects and then reconnects.
|
Cleanly disconnects and then reconnects.
|
||||||
"""
|
"""
|
||||||
self._log.debug('Closing current connection...')
|
self._log.info('Closing current connection to begin reconnect...')
|
||||||
await self._connection.disconnect()
|
await self._connection.disconnect()
|
||||||
|
|
||||||
await helpers._cancel(
|
await helpers._cancel(
|
||||||
|
@ -360,6 +360,7 @@ class MTProtoSender:
|
||||||
retries = self._retries if self._auto_reconnect else 0
|
retries = self._retries if self._auto_reconnect else 0
|
||||||
|
|
||||||
attempt = 0
|
attempt = 0
|
||||||
|
ok = True
|
||||||
# We're already "retrying" to connect, so we don't want to force retries
|
# We're already "retrying" to connect, so we don't want to force retries
|
||||||
for attempt in retry_range(retries, force_retry=False):
|
for attempt in retry_range(retries, force_retry=False):
|
||||||
try:
|
try:
|
||||||
|
@ -376,6 +377,9 @@ class MTProtoSender:
|
||||||
self.auth_key.key = None
|
self.auth_key.key = None
|
||||||
if self._auth_key_callback:
|
if self._auth_key_callback:
|
||||||
self._auth_key_callback(None)
|
self._auth_key_callback(None)
|
||||||
|
|
||||||
|
ok = False
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
self._log.warning('Invalid buffer %s', e)
|
self._log.warning('Invalid buffer %s', e)
|
||||||
|
|
||||||
|
@ -394,6 +398,9 @@ class MTProtoSender:
|
||||||
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
ok = False
|
||||||
|
|
||||||
|
if not ok:
|
||||||
self._log.error('Automatic reconnection failed %d time(s)', attempt)
|
self._log.error('Automatic reconnection failed %d time(s)', attempt)
|
||||||
await self._disconnect(error=last_error.with_traceback(None))
|
await self._disconnect(error=last_error.with_traceback(None))
|
||||||
|
|
||||||
|
@ -500,10 +507,11 @@ class MTProtoSender:
|
||||||
self.auth_key.key = None
|
self.auth_key.key = None
|
||||||
if self._auth_key_callback:
|
if self._auth_key_callback:
|
||||||
self._auth_key_callback(None)
|
self._auth_key_callback(None)
|
||||||
|
|
||||||
|
await self._disconnect(error=e)
|
||||||
else:
|
else:
|
||||||
self._log.warning('Invalid buffer %s', e)
|
self._log.warning('Invalid buffer %s', e)
|
||||||
|
self._start_reconnect(e)
|
||||||
self._start_reconnect(e)
|
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._log.exception('Unhandled error while receiving data')
|
self._log.exception('Unhandled error while receiving data')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user