Y
Y
YuriyCherniy2019-06-24 19:40:55
Python
YuriyCherniy, 2019-06-24 19:40:55

By what principle is timeout selected for a Telegram bot working through long polling?

There is a training bot written in Python without using third-party libraries. Timeout is set to 100, the polling cycle delay is set to 0.5 seconds, everything seems to be working. But these figures are set simply by the example of other bots from the Internet. I would like to understand what to build on when selecting these parameters?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladlen Hellsite, 2019-06-25
@YuriyCherniy

First of all, you need to understand the difference between polling and long polling.
Polling - After each period of time makes a request, the server returns a response instantly.
Long Polling - Waits for events and sends them on timeout.
The limit itself is selected based on the maximum waiting time of the Long Poll server and the connection itself (for example, a proxy). Let's say the maximum hold time is 60 seconds, but at the same time, many proxy servers terminate the connection after 30 seconds. Therefore, it would be logical to set it to 25 seconds.
And in this case, I suppose that they messed up a little, there is not timeout 100, but limit 100.
Link to the getUpdates method documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question