Skip to content

Commit 6752af8

Browse files
committed
Add error messages for transport errors
1 parent 526aaa0 commit 6752af8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pyrogram/session/session.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ class Session:
5353
PING_INTERVAL = 5
5454
STORED_MSG_IDS_MAX_SIZE = 1000 * 2
5555

56+
TRANSPORT_ERRORS = {
57+
404: "auth key not found",
58+
429: "transport flood",
59+
444: "invalid DC"
60+
}
61+
5662
def __init__(
5763
self,
5864
client: "pyrogram.Client",
@@ -292,7 +298,12 @@ async def recv_worker(self):
292298

293299
if packet is None or len(packet) == 4:
294300
if packet:
295-
log.warning('Server sent "%s"', Int.read(BytesIO(packet)))
301+
error_code = -Int.read(BytesIO(packet))
302+
303+
log.warning(
304+
"Server sent transport error: %s (%s)",
305+
error_code, Session.TRANSPORT_ERRORS.get(error_code, "unknown error")
306+
)
296307

297308
if self.is_started.is_set():
298309
self.loop.create_task(self.restart())

0 commit comments

Comments
 (0)