From e4f99df07c2f26be0966eeefdf18ac53e03e5b49 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 26 Apr 2021 16:09:39 +0200 Subject: [PATCH] Better error message in case of empty data in buffer --- pyrogram/crypto/mtproto.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyrogram/crypto/mtproto.py b/pyrogram/crypto/mtproto.py index bbe9d27a..dad30cd3 100644 --- a/pyrogram/crypto/mtproto.py +++ b/pyrogram/crypto/mtproto.py @@ -63,6 +63,9 @@ def unpack(b: BytesIO, session_id: bytes, auth_key: bytes, auth_key_id: bytes) - try: message = Message.read(data) except KeyError as e: + if e.args[0] == 0: + raise ConnectionError(f"Received empty data. Check your internet connection.") + left = data.read().hex() left = [left[i:i + 64] for i in range(0, len(left), 64)]