Telethon: Persistent timestamp empty error

Hi,

I run this code twice and in second run I get following exception:

client = TelegramClient("session", API_ID, API_HASH, proxy=(socks.SOCKS5, 'localhost', 8080),
                        spawn_read_thread=False)
client.connect()
client.catch_up()
client.disconnect()
Traceback (most recent call last):
  File "D:/work/bale/telegram_copier/telegram_bot/te.py", line 9, in <module>
    client.catch_up()
  File "C:\Python36\lib\site-packages\telethon\telegram_client.py", line 2445, in catch_up
    d = self(GetDifferenceRequest(state.pts, state.date, state.qts))
  File "C:\Python36\lib\site-packages\telethon\telegram_bare_client.py", line 486, in __call__
    result = self._invoke(call_receive, request, ordered=ordered)
  File "C:\Python36\lib\site-packages\telethon\telegram_bare_client.py", line 583, in _invoke
    raise next(x.rpc_error for x in requests if x.rpc_error)
telethon.errors.rpc_error_list.PersistentTimestampEmptyError: Persistent timestamp empty

P.S.: authentication done in previous runs and I give the session file with empty “update_state” table to this program.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (20 by maintainers)

Commits related to this issue

Most upvoted comments

This code produces the same error:

client = TelegramClient(session, api_id, api_hash, update_workers=1)

@client.on(events.NewMessage(incoming=True))
def my_event_handler(event):
    if event.is_private:
        event.reply('hi!')

client.connect()
client.catch_up()
client.disconnect()

Online updates handled just fine, but catch_up throws this exception. (without fix above)

UPDATE: With the fix above this code replying to every already received message on startup and then hangs in an infinite loop replying to all new messages twice (!) even though I have 1 update worker.

If I force-restart script it just pulls again the same updates and replies to them once more (and then hangs), although those updates were already handled.

P.S. I can provide you my session to reproduce and test this behavior.