S
S
Sanzhar Bazarbek2022-03-15 10:10:59
Python
Sanzhar Bazarbek, 2022-03-15 10:10:59

What to use Long Polling or Webhooks?

I am writing a telegram bot on Aiogram. Which will have to perform operations with money
After searching for information, I realized that it would work more reliably on webhooks.
But, I found a small amount of information on working with webhooks, and then, 5 years ago.
Now the question is, if you make a request to the server through long polling, will the script crash?
By setting skip_updates = False, and a while loop with sleep(0.5)?
Or should you do it right away on webhooks? I will be glad for good material on telegram webhooks from 0

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Elvis, 2022-03-15
@Dr_Elvis

do it right away on webhooks. polling is convenient only for a short-term attachment of a bot. for a permanent stable webhook connection. the difference is that the polling itself constantly polls the server "is there anything for me?", to which the server either issues data or not. and webhooks are like "here is my address, the data came when it appears" and sits waiting for the telegram server to send something.

H
HemulGM, 2022-03-16
@HemulGM

To work on webhooks, you need not only to raise an http server, but also to have your own permanently available host - a machine and a permanent white ip address and domain. All this costs money. Whereas polling works from anywhere without the need to have a permanent ip address. And also, you can use for free, for example, heroku for hosting a script

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question