Answer the question
In order to leave comments, you need to log in
Why is the bot interrupted?
Hello! The problem is the following: when you start the bot, it works fine for a while, but then, when you don’t access it for 10-15 minutes, an error occurs:
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'Удаленный хост принудительно разорвал существующее подключение', None, 10054, None))
Answer the question
In order to leave comments, you need to log in
This is a problem on the side of the telebot library. There are two ways out:
1) You set the program to run using the systemd utility. In it, in the [service] setting, specify Restart=on-failure. In this case, if the script terminates, systemd will restart it. Well, or put a restart every 30-60 minutes.
2) You pass and rewrite on aiogram. In 2015-2017, perhaps, telebot was relevant, but progress does not stand still. And telebot, alas, is worth it. Poor polling implementation, problematic next_step_handler, slow support for new Bot API versions, etc.
Arguments for switching to aiogram:
Take in try / except and set a timer
try:
#Твой код
except:
time.sleep(10) # Таймер на 10 секунд
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question