tgbot-cpp icon indicating copy to clipboard operation
tgbot-cpp copied to clipboard

TgLongPoll locks the thread after working some time

Open MrVolot opened this issue 2 years ago • 4 comments

So, the problem is that I have such code which start the whole bot workflow: while (true) { try { setEvents(); printf("Bot username: %s\n", bot->getApi().getMe()->username.c_str()); TgBot::TgLongPoll longPoll(*bot); while (true) { printf("Long poll started\n"); longPoll.start(); } } catch (...) { printf("Error. Restart is happening \n"); bot.reset(new Bot{ token }); } } After some time of bot working, the longPoll.start() locks the whole thread and stops doing anything. is there a reason for such behaviour and is there a way to handle it?

MrVolot avatar Jan 31 '23 22:01 MrVolot

No, that's not supposed to happen. How long does it take for the thread to be locked?

llnulldisk avatar Feb 05 '23 15:02 llnulldisk

The main problem is that I don't know any reason for this to happen. I didn't wait the thread to be unlocked. I waited only for 2 hours and then I restarted the program for it to work.

MrVolot avatar Feb 05 '23 16:02 MrVolot

I had a thought that the issue might appear due to internet connection instability but I tested out turning off internet and turning it in back and the reconnection was done without any troubles, so I believe it is not the case.

MrVolot avatar Feb 05 '23 16:02 MrVolot

No, that's not supposed to happen. How long does it take for the thread to be locked?

I have added some descriptions above but I didn't measure in time after waiting for 2 hours.

MrVolot avatar Feb 05 '23 19:02 MrVolot