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

Real-Time User Presence Updates Appear Stale – Unable to Bypass Caching #3258

Open
IdanAlbilia opened this issue Feb 26, 2025 · 3 comments

Comments

@IdanAlbilia
Copy link

IdanAlbilia commented Feb 26, 2025

I'm experiencing issues with real-time user presence updates in TDLib. Despite setting up listeners for updateUserStatus events and polling for user status every 10 seconds using methods like TdApi.GetUser, the returned status data often appears outdated.

After reviewing the TDLib source—specifically in the UserManager::on_update_user_online methods—it seems that the internal caching mechanism might be preventing fresh data from being fetched promptly.

Steps to Reproduce:
Initialize a TDLib client with a standard session and caching enabled.
Subscribe to user status updates (e.g., via updateUserStatus).
Poll for many user presence using TdApi.GetUser every 10 seconds. (some users will work some won't)
Observe that the status information (such as was_online) does not update in real-time, even when updates are expected.

Expected Behavior:
User presence updates should reflect the current online status almost immediately when the status changes on the server.

Actual Behavior:
The status information appears to be cached, and even though update events are received (as seen in the on_update_user_online function), the cached value does not refresh quickly enough, resulting in stale status data.

Questions/Request for Guidance:
Cache Invalidation: Is there a supported way to clear or bypass the TDLib cache for user status data without disconnecting or restarting the client?
Feature Request: Could a mechanism be introduced to force a refresh of cached user presence data, or allow developers to disable caching for specific API calls?
Workarounds: Are there recommended workarounds to obtain real-time presence updates given the current caching behavior?

Any insights, workarounds, or plans for addressing this behavior would be greatly appreciated. Thank you for your time and support!

@levlam
Copy link
Contributor

levlam commented Feb 26, 2025

This is intended behavior. It is impossible to know exact status of all other Telegram users and this is never needed by real app users. The information is updated whenever needed and updates are sent after that.

@IdanAlbilia
Copy link
Author

While I understand that this behavior is intended, would it be possible to introduce an optional mode for applications that require more immediate presence updates? My use case depends on near real-time user status information, and I'm wondering if there are any recommended workarounds or plans for future improvements in this area.

@levlam
Copy link
Contributor

levlam commented Feb 27, 2025

No, it isn't possible.

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