Telethon stops responding after repeated [client.updates] Timeout waiting for updates expired
[DEBUG] telethon.client.updates: Timeout waiting for updates expired
Expected behavior
Telethon should continue to handle updates and respond to API requests (such as get_me(), send_message(), etc.) even after periods of inactivity or high message traffic.
Specifically, seeing the log line:
[DEBUG] telethon.client.updates: Timeout waiting for updates expired
…should not cause the client to stop processing further updates or become unresponsive.
Reproduction steps
Unfortunately, I don’t have a minimal script yet, but here’s the general setup:
- Create a Telethon client connected to a user or bot account.
- Start
py-tgcallsfor group voice streaming (running on the same event loop). - Let the bot run for ~30–60 minutes in a moderately active chat.
- Eventually, the above log message starts repeating.
- After that, the bot no longer responds to any Telethon API calls, even though the event loop is still running.
A restart of the process restores normal behavior temporarily.
Actual behavior
Summary
I'm encountering an issue where Telethon becomes unresponsive and stops handling further API requests after repeatedly logging the following debug message:
[DEBUG] telethon.client.updates: Timeout waiting for updates expired
Once this message starts appearing, my bot no longer responds to any Telethon operations — including get_me(), send_message(), and even get_dialogs(). The only solution is to restart the process.
Context
I'm using Telethon along with py-tgcalls (for group voice streaming). The issue typically appears after some runtime (30–60 minutes), especially under higher load or activity.
Observations
- The logs are flooded with
Timeout waiting for updates expired. py-tgcallsstill runs, but Telethon doesn't seem to process any further events.- Restarting the event loop (i.e., restarting the bot) resolves it temporarily.
- I suspect that the update mechanism or internal state may be locked or stalled.
Reproduction
Although I haven't found a minimal reproducible script yet, the issue seems more likely to happen when:
- There are active group calls.
- Telethon is under load (many updates/messages).
py-tgcallsis interacting with the same event loop.
Versions
- Telethon: 1.40.0
- py-tgcalls: 2.2.0rc3
- Python: 3.12
- OS: Ubuntu 22
Any suggestions?
Let me know if there's any way to detect or avoid this state programmatically — or if it's worth isolating in a minimal example. I'm happy to help debug further.
Thanks for your work!
Traceback
No response
Telethon version
1.40.0
Python version
3.12.3
Operating system (including distribution name and version)
Ubuntu 22.04.5 LTS
Other details
No response
Checklist
- [x] The error is in the library's code, and not in my own.
- [x] I have searched for this issue before posting it and there isn't an open duplicate.
- [x] I ran
pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zipand triggered the bug in the latest version.
Appreciate the detailed report, unfortunately don't think I'll look into this any time soon. I would be surprised if Telethon is getting "locked up" though, as I'd expect to have heard about it sooner. If pings are still going out and being answered periodically, the library continues to work just fine.
Maybe periodically calling client.get_difference will help, maybe not.