reo7sp / tgbot-cpp

C++ library for Telegram bot API
http://reo7sp.github.io/tgbot-cpp
MIT License
1.01k stars 245 forks source link

TgLongPoll locks the thread after working some time #258

Open MrVolot opened 1 year ago

MrVolot commented 1 year ago

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?

llnulldisk commented 1 year ago

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

MrVolot commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.