diff --git a/telethon/network/connection.py b/telethon/network/connection.py index 0adaf98a..a8c70876 100644 --- a/telethon/network/connection.py +++ b/telethon/network/connection.py @@ -191,10 +191,13 @@ class Connection: __log__.error('Read invalid packet length %d, ' 'reading data left:', packet_len) while True: + data = b'' try: - __log__.error(repr(self.read(1))) + data += self.read(1) except TimeoutError: break + finally: + __log__.error(repr(data)) # Connection reset and hope it's fixed after self.conn.close() raise ConnectionResetError()