From d505b2f37289f112e714ad5645d21718ddd3ad7b Mon Sep 17 00:00:00 2001 From: omg-xtao <100690902+omg-xtao@users.noreply.github.com> Date: Sun, 11 Feb 2024 21:51:47 +0800 Subject: [PATCH] Fix ConnectionResetError when only ping task (#24) --- pyrogram/session/session.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index 7206050d..e5b53d17 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -285,7 +285,10 @@ class Session: ping_id=0, disconnect_delay=self.WAIT_TIMEOUT + 10 ), False ) - except (OSError, RPCError): + except OSError: + self.loop.create_task(self.restart()) + break + except RPCError: pass log.info("PingTask stopped")