mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-02 20:54:43 +03:00
Invoke getState after the server kicks us idling for updates
For some reason, the server seems to kick us after 1024 items from the network are received. Tested with the following code, 1022 updates were received, after BadServerSalt, NewSessionCreated and MsgsAck: client = TelegramClient(..., spawn_read_thread=False) client.connect(_sync_updates=False) sender = client._sender client = None while True: try: sender.receive(None) except TimeoutError: pass except ConnectionResetError: sender.connect() If one were to run this code after being kicked no further items will be retrieved and it will always timeout. Invoking a ping has no effect either. Invoking some "high level" request like getState seems to do the trick.
This commit is contained in:
parent
eefd37c2d7
commit
341fb38136
|
@ -664,6 +664,14 @@ class TelegramBareClient:
|
|||
with self._reconnect_lock:
|
||||
while self._user_connected and not self._reconnect():
|
||||
sleep(0.1) # Retry forever, this is instant messaging
|
||||
|
||||
if self.is_connected():
|
||||
# Telegram seems to kick us every 1024 items received
|
||||
# from the network not considering things like bad salt.
|
||||
# We must execute some *high level* request (that's not
|
||||
# a ping) if we want to receive updates again.
|
||||
# TODO Test if getDifference works too (better alternative)
|
||||
self._sender.send(GetStateRequest())
|
||||
except:
|
||||
self._idling.clear()
|
||||
raise
|
||||
|
|
Loading…
Reference in New Issue
Block a user