-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
NewMessage event callback taking too long to be triggered on big channels #652
Comments
Telethon/telethon/telegram_bare_client.py Lines 635 to 649 in 229cd78
No sleeps. As little delay as possible. The Telethon/telethon/network/mtproto_sender.py Lines 132 to 134 in 229cd78
As soon as an update arrive it gets processed on the (updates) state: Telethon/telethon/network/mtproto_sender.py Lines 258 to 259 in 229cd78
Then one of many workers poll these queue: Telethon/telethon/update_state.py Lines 105 to 111 in 229cd78
If you can spot the bottleneck (is it in the code, or is Telegram itself actually taking long to deliver the updates?) and you can think of a fix, I'd appreciate :) |
@victorbrjorge |
Bump. Any update on this? I'm averagely getting ~5 sec delay. Even on semi-big channels (6k users). Unfortunately I didn't find any bottleneck in Telethon. Thanks. |
Do you guys constantly receive updates during that time and, by the time update X arrives it's been delayed by a certain amount of time, or you receive no updates at all and then X arrives delayed? If the former, note that deserializing also takes a while so maybe that's the reason. Other than that like I stated I'm constantly reading from the socket already. Although |
@Lonami For me it seems like the first variant.
How I measure the delay:
Messages are mostly text-only. 200 char max. They contain some emoticons from time-to-time. |
Update:
The first number is current time (seconds.millis) Another:
|
Some words from @delivrance and ed (adapted for this issue):
So probably not much we can do. Feel free to investigate further to check whether the server is just slow sending the updates or what's going on. Maybe create a clean account and simply call |
I might add, I haven't noticed any delays, but I'm not in big groups or channels either besides @Telegram, which hardly ever posts. |
hello, I believe I am experiencing a similar issue. Is there any fix or is it telegram's API? notifications for my own channel go through instantly but Binance (huge obv) has a 30 second delay. |
There's a |
Hi @Lonami - I apologise for resurrecting an old thread. I've been running in the same issues and have noticed Pyrogram is much faster using the exact same code to receive new messages, this would suggest that there is something in the library? For moderate channels, I'm seeing results such as: | --- Message from 146xxxx59 --- I'm not 100% sure if this is because they pull the difference more often or not, but just thought I'd let you know. This is consistent over a lot of messages, not a single sample size (using the same channel with approx 4-5000 users). Code for Telethon:
Code for Pyrogram:
|
The same delay has been observed in the opposite direction (Telethon fast, other libraries slow). I can't speak for what others are doing. Telethon relies on Telegram to send updates as soon as possible, and if it doesn't, then well, delays occur. I believe I have already checked and there is almost no delay between "network packet" and "handle update" (so the slow part is Telegram delivering the update). |
But it's not work in channels with many subscribers. See more LonamiWebs/Telethon#652
I am also facing same issue but less delay like 1 or 2 or 3 or 5 seconds, But i need to get 0 sec delay means it should arrive when it sent, Is that delay problem solved? please provide some information or code regarding to that, so that will very helpful for those who are facing this issue. |
Hi, guys! I'm facing the exact same issue. The NewMessage event is taking too long, anyone haves a solution? |
+1 Been noticing this for a couple weeks now and it's quite suboptimal to say the least. Surprised to see this issue from 6y ago with no clear findings. |
Hi, guys! I'm facing the exact same issue. The NewMessage event is taking too long, anyone haves a solution? |
+1 |
I have the same issue. Anyone can confirm that Pyrogram is better with delays than Telethon? |
same issue I am facing |
Same here! I cannot find how to make it since by looking for "poll" in Telegram I found so many ""survey"" stuff instead which make a lot of noise... |
I have an app that uses Telethon to listen to messages from some big channels (2k+ subscribers) and relay them. Since version 0.17 I've been noticing some delays in it. So I made the code below to test if the delay was on Telethon and discovered that telethon has been taking over 20s average to run the callback function.
OUT:
When listening from a test channel with just me as a subscriber, there is no delay. I've been thinking about rolling back my Telethon version, but maybe you guys can help me with it.
UPDATE:
I rolled back the version of the library to 0.16.2 and the issue still persists. I guess it has something to do with the Telegram API itself. Anyway, can anyone help me with this, regardless?
The text was updated successfully, but these errors were encountered: