aahnik/webhook-aiogram-heroku

Bot reponds twice to a message when waken up from sleep. ๐Ÿคจ๐Ÿ˜’๐Ÿ˜”

aahnik opened this issue ยท 1 comments

heroku sleeps the bot when not used for 30 min.

suppose bot is sleeping now, and i send a message. it will reply twice to that message after waking up.

then everything becomes normal.

why this happens ?

I have followed the official example. In the on_shutdown I have removed delete webhook,Becos then heroku won't receive any updates and would not be able to wake up the bot

I have found a solution to this.

setting drop_pending_updates=True while set_webhook will solve it.

I realized that the working of set_webhook in aiogram is much different from ptb.

In aiogram, set_webhook must be called on_startup. Other wise bot will not work.

Suppose you set webhook earlier, ( and dont delete it ); and in your on startup you just log "starting". Then bot will not work.

You must call set_webhook on startup.

In ptb, although, you can set webhook just once and forget about it. ( may have to delete it, if you switch to polling )

this is my realization from my experiments ( in heroku ).

If anybody has related experience, please share/confirm.