From 89326c998a589f8b9ccff5e270ecb39e95383b8d Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 21 Apr 2017 14:02:21 +0200 Subject: [PATCH] Workaround for #50 suggested by @strayge (send not only Ping) --- telethon/network/mtproto_sender.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/telethon/network/mtproto_sender.py b/telethon/network/mtproto_sender.py index 660ab0b9..498bc8fb 100755 --- a/telethon/network/mtproto_sender.py +++ b/telethon/network/mtproto_sender.py @@ -8,6 +8,7 @@ from telethon.crypto import AES from telethon.errors import * from telethon.log import Log from telethon.tl.all_tlobjects import tlobjects +from telethon.tl.functions.updates import GetStateRequest from telethon.tl.types import MsgsAck from telethon.tl.functions import PingRequest from telethon.utils import BinaryReader, BinaryWriter @@ -80,7 +81,7 @@ class MtProtoSender: def send_ping(self): """Sends PingRequest""" - request = PingRequest(0) + request = PingRequest(utils.generate_random_long()) self.send(request) self.receive(request) @@ -436,6 +437,12 @@ class MtProtoSender: except TimeoutError: Log.d('Receiving updates timed out') + # TODO Workaround for issue #50 + Log.d('Sending GetStateRequest (workaround for issue #50)') + r = GetStateRequest() + self.send(r) + self.receive(r) + except ReadCancelledError: Log.i('Receiving updates cancelled') except OSError as e: