Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram Bot webhook really slow

I've created a telegram bot and set a webhook as described in the docs. For testing purposes I've set it up so once you send the bot a message it replies back with the same message.

Now the issue I am having is that the updates from telegram are coming back really slowly and there are some messages I haven't received yet. Am I missing something or is the webhook method just really slow?

like image 358
user1686342 Avatar asked May 02 '16 12:05

user1686342


People also ask

How can I speed up my telegram bot?

Server location is really important if you want a really fast bot! The distance between your server and Telegram servers adds a delay in your responce time. The closer your server is to Telegram ones the ligher the lighter the delay becomes!

Is there any problem using Telegram bot?

Security researchers have previously found Telegram bots that command and control malicious Android apps, and even exfiltrate data from Telegram chats through the Telegram bot API used by developers.

Is Webhook long polling?

The main advantage of webhooks over long polling is that they are cheaper. You save a ton of superfluous requests. You don't need to keep a network connection open at all times. You can use services that automatically scale your infrastructure down to zero when no requests are coming.

Which server is best for Telegram bot?

Oracle Cloud It is more than capable of hosting a Telegram bot using its functions service in the PaaS branch.


1 Answers

I had the same problem. Turns out I wasn't responding the telegram server after I got the POST request. Due to this, the server wasn't sure if I got the previous updates and was constantly sending my webhook past updates.

I have an express server and I added this bit of line after handling the POST Request.

res.sendStatus(403)

You can also confirm this by going to this url

https://api.telegram.org/<token>/getWebhookInfo

You'll see a property called pending_update_count. It should zero or close to it.

like image 122
Aditya Avatar answered Oct 21 '22 00:10

Aditya