I have my Telegram bot deployed to GCP cloud run. It works fine even when instances get scaled to 0 - when Telegram calls, the instance starts and the bot receives the updates.
But sometimes, in unknown circumstances:
What's interesting is that if I call the getWebhookInfo
method:
{
"ok": true,
"result": {
"url": "https://my-host/telegram/webhook",
"has_custom_certificate": false,
"pending_update_count": 0,
"max_connections": 40,
"ip_address": "35.000.00.000",
"allowed_updates": [
"message"
]
}
}
Then Telegram does send updates right after my call, kinda when I remind about myself. Imagine the case:
getWebhookInfo
Update:
the app when it starts upon request calls setWebhookMethod
and in most cases, it returns Webhook is already set
but sometimes it returns Webhook was set
which means
Telegram forgets about my webhook in unknown circumstances. Though my bot doesn't call the deleteWebhook
endpoint
What can be wrong?
I don't have any firewall rule other than default.
The certificate is okay as it's managed by Google.
I tried with a static IP (load balancer) and w/o - same case.
I thought it's about "allowed_updates": [ "message" ]
but no - it's set now always and no updates.
I couldn't figure out the exact reason. I tried using static IP too but it didn't help either.
The closet assumption is that my bot, given the framework I use - kotlin-telegram, sets the webhook during the actual webhook request from Telegram (it does it during the application startup and I have it serverless, it starts e).
I did the following workaround: