mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Handle IncompleteReadError and InvalidChecksumError
This commit is contained in:
@@ -9,7 +9,7 @@ from .requeststate import RequestState
|
||||
from .. import utils
|
||||
from ..errors import (
|
||||
BadMessageError, BrokenAuthKeyError, SecurityError, TypeNotFoundError,
|
||||
rpc_message_to_error
|
||||
InvalidChecksumError, rpc_message_to_error
|
||||
)
|
||||
from ..extensions import BinaryReader
|
||||
from ..helpers import _ReadyQueue
|
||||
@@ -376,6 +376,11 @@ class MTProtoSender:
|
||||
__log__.warning('Security error while unpacking a '
|
||||
'received message: %s', e)
|
||||
continue
|
||||
except InvalidChecksumError as e:
|
||||
__log__.warning(
|
||||
'Invalid checksum on the read packet (was %s expected %s)',
|
||||
e.checksum, e.valid_checksum
|
||||
)
|
||||
except asyncio.CancelledError:
|
||||
return
|
||||
except (BrokenAuthKeyError, BufferError):
|
||||
@@ -383,6 +388,13 @@ class MTProtoSender:
|
||||
self._connection._state.auth_key = None
|
||||
self._start_reconnect()
|
||||
return
|
||||
except asyncio.IncompleteReadError:
|
||||
# TODO Handle packets that are too big and trigger this
|
||||
# If it's not a packet that triggered this, just reconnect
|
||||
__log__.info('Telegram closed the connection')
|
||||
self._pending_state.clear()
|
||||
self._start_reconnect()
|
||||
return
|
||||
except Exception:
|
||||
__log__.exception('Unhandled error while receiving data')
|
||||
self._start_reconnect()
|
||||
|
Reference in New Issue
Block a user