Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error messages clogging Telethon resulting in security error: Server sent a very new message xxxxx was ignored

I am really at a loss here, recently migrated to new machine and telethon has just broken down it seems. I've checked with others, so its probably just me, but I can't figure out how to solve this problem as it appears to be server side/telethon, but as it seems to be on my end it doesn't seem so obvious.

Whenever launching telethon from an existing session I receive two error messages:

Server sent a very new message with ID xxxxxxxxxxxxxxxxxxx, ignoring
Server sent a very new message with ID xxxxxxxxxxxxxxxxxxx, ignoring

And thereafter it gets clogged with the follow error messages, preventing any execution:

[WARNING/2022-09-07] telethon.network.mtprotosender: Security error while unpacking a received message: Too many messages had to be ignored consecutively

I've attached some standard code which reproduce this error for me. Could someone please give me a heads-up on whats causing this? And what to do about it? Running 3.10 Python and latest Telethon from pip.

from telethon import TelegramClient, events
from telethon.sessions import StringSession

api_id = 1xxxxxxxxxx
api_hash = '2xxxxxxxxxxxxx'
ph = '+1xxxxxxxxxxxxxxxx' 
key = 'xxxxxx...'

#client = TelegramClient('session', api_id, api_hash).start(phone = ph)
client = TelegramClient(StringSession(key), api_id, api_hash).start(phone = ph)

channelId = 'xxxxxxx'

@client.on(events.NewMessage(chats = [channelId]))
async def main(event):
     try:
         me = client.get_me()
         print(me.stringify())
         print(event.stringify())
     except Exception as e:
         print(e)
    

client.run_until_disconnected()
like image 383
Joey de La Moey Avatar asked Sep 12 '25 19:09

Joey de La Moey


2 Answers

I had the same problem in version 1.25.2. Solution, in Windows time settings, enable automatic setting of time and time zone

like image 67
Wolf1407 Avatar answered Sep 14 '25 10:09

Wolf1407


If you're using WSL (Windows Subsystem for Linux) to run your Python code that uses Telethon, it is still crucial that "Set time zone automatically" is enabled under "Time & Language" > "Date & Time" settings in Windows, in order to avoid that "Server sent a very new message (..) was ignored" issue.

I tried killing sessions from the Telegram desktop app, changing the App Name (and its short name) in https://my.telegram.org, etc. and this is the only solution that worked for me!

like image 34
Pierre-Yves Brisson Avatar answered Sep 14 '25 09:09

Pierre-Yves Brisson