Написал своего первого бота, ночью когда никто им не пользуется выбивает такую ошибку,
как можно исправить?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/bot/index.py", line 1180, in <module>
bot.polling(none_stop=True, interval=2)
File "/usr/local/lib/python3.9/dist-packages/telebot/__init__.py", line 1047, in polling
self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "/usr/local/lib/python3.9/dist-packages/telebot/__init__.py", line 1122, in __threaded_polling
raise e
File "/usr/local/lib/python3.9/dist-packages/telebot/__init__.py", line 1077, in __threaded_polling
polling_thread.raise_exceptions()
File "/usr/local/lib/python3.9/dist-packages/telebot/util.py", line 116, in raise_exceptions
raise self.exception_info
File "/usr/local/lib/python3.9/dist-packages/telebot/util.py", line 98, in run
task(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/telebot/__init__.py", line 653, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1),
File "/usr/local/lib/python3.9/dist-packages/telebot/__init__.py", line 627, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
File "/usr/local/lib/python3.9/dist-packages/telebot/apihelper.py", line 334, in get_updates
return _make_request(token, method_url, params=payload)
File "/usr/local/lib/python3.9/dist-packages/telebot/apihelper.py", line 156, in _make_request
result = _get_req_session().request(
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=25)
На просторах интернета находил решение этой проблемы, но не помогло, вот такой код нерабочего решения:
while True:
try:
logging.info("Bot running..")
bot.polling(none_stop=True, interval=2)
# Предполагаю, что бот может мирно завершить работу, поэтому
# даем выйти из цикла
break
except telebot.apihelper.ApiException as e:
logging.error(e)
bot.stop_polling()
time.sleep(15)
logging.info("Running again!")