Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stops recieving messages after 10-20 hours #4521

Open
3 tasks done
AustinTurney opened this issue Dec 24, 2024 · 1 comment
Open
3 tasks done

Stops recieving messages after 10-20 hours #4521

AustinTurney opened this issue Dec 24, 2024 · 1 comment

Comments

@AustinTurney
Copy link

Code that causes the issue

async def main():
    await client.start(phone=phone_number)  # Start the client
    print("Listening for messages...")
    await client.run_until_disconnected()  # Keep the client running   

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

Expected behavior

The program would run until disconnected or user interrupted

Actual behavior

after 10-20h the program stop logging messages. I then have to manually interrupt the program and restart the script.

Traceback

The last log is usually this:

2024-12-21 11:31:39,980 - WARNING - Server sent a very old message with ID xxxxxxxxxxxxxxxx, ignoring (see FAQ for details)
2024-12-21 11:31:39,980 - WARNING - Security error while unpacking a received message: Too many messages had to be ignored consecutively

Telethon version

1.38.1

Python version

3.11.9

Operating system (including distribution name and version)

Windows 10

Other details

No response

Checklist

  • The error is in the library's code, and not in my own.
  • I have searched for this issue before posting it and there isn't an open duplicate.
  • I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip and triggered the bug in the latest version.
@Sal0ID
Copy link

Sal0ID commented Dec 24, 2024

I use telethon for 24/7 monitoring of specific telegram channels, have not encountered any problems yet. Here is my code:

from telethon import TelegramClient, events

# Create a Telegram client
client = TelegramClient(SESSION_NAME, API_ID, API_HASH)

async def main():
    print("Starting Telegram client...")
    await client.start()
    await client.run_until_disconnected()
    
if __name__ == "__main__":
    import asyncio
    asyncio.run(main())
    
@client.on(events.NewMessage())
async def new_message_handler(event):
    #Your program goes here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants