2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-22 09:57:19 +00:00

Add error messages for transport errors

This commit is contained in:
Dan 2022-12-31 19:01:42 +01:00
parent 526aaa0f9d
commit 6752af8796

View File

@ -53,6 +53,12 @@ class Session:
PING_INTERVAL = 5
STORED_MSG_IDS_MAX_SIZE = 1000 * 2
TRANSPORT_ERRORS = {
404: "auth key not found",
429: "transport flood",
444: "invalid DC"
}
def __init__(
self,
client: "pyrogram.Client",
@ -292,7 +298,12 @@ class Session:
if packet is None or len(packet) == 4:
if packet:
log.warning('Server sent "%s"', Int.read(BytesIO(packet)))
error_code = -Int.read(BytesIO(packet))
log.warning(
"Server sent transport error: %s (%s)",
error_code, Session.TRANSPORT_ERRORS.get(error_code, "unknown error")
)
if self.is_started.is_set():
self.loop.create_task(self.restart())