Closed dmikushin closed 1 year ago
@JellyBrick I mean, the HTTP request timeout is too ordinary to be an exception. In my network, it occurs like multiple times a day. Therefore, handling each occurrence with an extension is too much. Note that each exception in this context invalidates the bot instance. Bot has to be recreated from scratch, with a good chance of memory leak. As for the network service, this could be even considered a vulnerability.
Consider USB stack, which has something similar. They have UNIX pipe timeout, which is in fact an exception. The same logic as yours could have been applied, but it is not. The timeout is so ordinary, that the code gives to the pipe a lot of trials before giving up.
Hello, I've tested this PR and added some more fixes. Now the bot runs flawlessly for more than two weeks are survives network outages. @JellyBrick @reo7sp , could you please review and merge? Thank you.
I've been using tgbot-cpp in production for half a year, and its most recent execution is already up for 60 days. In order to bring this nice stability, I had to handle periodic outages of network and/or telegram endpoint timeout in a more recoverable way. The thing is currently we throw an exception in case the HTTP request fails. I changed that to repeat request with a timeout until it succeeds. To me it seems a fairly reasonable design, even by default. What do you think?