diff --git a/pyrogram/connection/transport/tcp/tcp.py b/pyrogram/connection/transport/tcp/tcp.py index 168f06a5..08a435ce 100644 --- a/pyrogram/connection/transport/tcp/tcp.py +++ b/pyrogram/connection/transport/tcp/tcp.py @@ -101,6 +101,7 @@ class TCP: await self.writer.drain() except Exception as e: log.warning("Send exception: %s %s", type(e).__name__, e) + raise OSError(e) async def recv(self, length: int = 0): data = b"" diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index e64ea793..6a7fc505 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -297,7 +297,11 @@ class Session: self.auth_key_id ) - await self.connection.send(payload) + try: + await self.connection.send(payload) + except OSError as e: + self.results.pop(msg_id, None) + raise e if wait_response: try: