Intermittent Message Reception Delays and Bursts in Telethon
wskxjtzq opened this issue · comments
Code that causes the issue
from telethon import TelegramClient, events
api_id = 77777
api_hash = '777777777777'
phone_number = ""
password = ""
client = TelegramClient('xcoder', api_id, api_hash, system_version="4.16.30-vx_computer")
@client.on(events.NewMessage)
async def my_event_handler(event):
sender = await event.get_sender()
chat_id = event.chat_id
sender_id = event.sender_id
print(f"message,from {chat.title} {chat_id} {sender_id}:{event.raw_text}。")
client.start(phone_number, password)
client.run_until_disconnected()
Expected behavior
I am encountering an issue with Telethon while using it to connect to Telegram's API. Previously, a few years ago, the same code worked smoothly, allowing me to receive messages from group chats without any noticeable delays.
Actual behavior
However, when I recently attempted to reconnect using the same code, although messages are still received, their reception seems abnormal. There are long periods (many minutes) where no messages arrive, giving the impression that the messages are stuck, followed suddenly by receiving dozens of messages in a burst.
Traceback
No response
Telethon version
1.36.0
Python version
3.11
Operating system (including distribution name and version)
windows 11
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.