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

How to set timeout getUpdates #562

Closed
RealYukiSan opened this issue Mar 28, 2024 · 4 comments
Closed

How to set timeout getUpdates #562

RealYukiSan opened this issue Mar 28, 2024 · 4 comments

Comments

@RealYukiSan
Copy link

the telegram bot docs says the time unit is in seconds, but when I try to set to 5 minutes (300 sec) it didn't work

time curl --keepalive-time 300 https://api.telegram.org/bot<token>/getUpdates?timeout=300&offset=<last update_id + 1>
real    0m50.585s
user    0m0.036s
sys     0m0.016s
@levlam
Copy link
Contributor

levlam commented Mar 28, 2024

There are no reasons to wait for 5 minutes before sending response. Such big timeouts can make bots too unreliable.

@RealYukiSan
Copy link
Author

To optimize performance and minimize resource usage, I'd like to establish a persistent connection and wait indefinitely for a non-empty result. This approach eliminates the overhead of repeatedly opening and closing connections.

@levlam
Copy link
Contributor

levlam commented Mar 28, 2024

and wait indefinitely for a non-empty result. This approach eliminates the overhead of repeatedly opening and closing connections.

This approach makes your connections unreliable. You may never know that TCP connection has failed and will never return you any data.

@RealYukiSan
Copy link
Author

If the worst case happened, re-connecting would be the last option.
anyway I will close the issue, thanks for the response!

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