I'm developing a Telegram bot using python-telegram-bot
to send messages and FastApi
to get webhooks from Telegram. I have successfully setWebhook()
with correct url, opened 443 port, obtained the ssl certificate by Let's Encrypt and launched the web server. The problem is when I click on a button, command or send the message to bot it takes around 30-60 seconds to webhook to reach my server. It is inconsistent and the bot could work as expected for 30 messages but than got delayed again for some time, or may be delayed after the first command straight.
Actually there is a Facebook Messenger Bot in my application as well with its' webhook handler which is working totally fine for all the time. So when telegram stuck I can successfully communicate with the bot in messenger.
While developing the server was launched locally using ngrok
and all worked fine, both telegram and facebook bots. I have already checked the firewall rules, tried to create new bots, revoked API tokens, deployed on different VM with self-signed certificate but nothing worked and delay still here. I have also checked different metrics, networks on google cloud trying to indicate the problem but it seems good for me. Also using tcpdump
I have noticed that when delay occurred after I click the button there are no requests from telegram to the server and when it finally sent the server answered with no issues.
Does anyone have faced the same issue? Any advise how to investigate the problem?