diff --git a/telethon/network/connection/connection.py b/telethon/network/connection/connection.py index 2b2dc55a..d6a916b2 100644 --- a/telethon/network/connection/connection.py +++ b/telethon/network/connection/connection.py @@ -13,7 +13,7 @@ try: except ImportError: python_socks = None -from ...errors import InvalidChecksumError +from ...errors import InvalidChecksumError, InvalidBufferError from ... import helpers @@ -336,6 +336,9 @@ class Connection(abc.ABC): elif isinstance(e, InvalidChecksumError): msg = 'The server response had an invalid checksum' self._log.info(msg) + elif isinstance(e, InvalidBufferError): + msg = 'The server response had an invalid buffer' + self._log.error(msg) else: msg = 'Unexpected exception in the receive loop' self._log.exception(msg) diff --git a/telethon/network/connection/tcpfull.py b/telethon/network/connection/tcpfull.py index 7ebbbe6f..5fc5613f 100644 --- a/telethon/network/connection/tcpfull.py +++ b/telethon/network/connection/tcpfull.py @@ -2,7 +2,7 @@ import struct from zlib import crc32 from .connection import Connection, PacketCodec -from ...errors import InvalidChecksumError +from ...errors import InvalidChecksumError, InvalidBufferError class FullPacketCodec(PacketCodec): @@ -24,6 +24,13 @@ class FullPacketCodec(PacketCodec): async def read_packet(self, reader): packet_len_seq = await reader.readexactly(8) # 4 and 4 packet_len, seq = struct.unpack('