Stopping a receiving messages when an error occurs
When an error occurs in HandleUpdateAsync and HandleErrorAsync methods, bot stop receiving messages.
Is that how it's supposed to work?
https://github.com/TelegramBots/Telegram.Bot.Extensions.Polling/blob/52c1edf4ff13d97c0b6d5ed8a62631cceadd9210/src/Telegram.Bot.Extensions.Polling/DefaultUpdateReceiver.cs#L99-L115
Yes, that's the expected behaviour, it's the same as with previous events in the client.
If there's an exception in user code we can't do anything other than stop execution.
How should I restart receiver when an exception throwing?
If there is an exception in the user code, then we will fall into updateHandler.HandleErrorAsync, which is called in https://github.com/TelegramBots/Telegram.Bot.Extensions.Polling/blob/52c1edf4ff13d97c0b6d5ed8a62631cceadd9210/src/Telegram.Bot.Extensions.Polling/Extensions/TelegramBotClientPollingExtensions.cs#L158.
It turns out that HandleErrorAsync will be called not only to handle receiving updates, but also to handle custom code in updateHandler.HandleUpdateAsync
There is a way to automatically restart the bot after an exception? I also have the same problem, but I'm receiving exception because a user has blocked the bot. I don't want to wrap each call to sendMessageAsync with a try-catch to avoid interruption, is there another way?
#1106
i have this problem, my bot stop receiving messages for any problem and after restarting bot , it working fine again. how i can restart bot automatically when an error occur ?