bot.download_file causes Aiohttp ClientError: ClientOSError
Opened this issue · 3 comments
yudytskiy commented
Hi.
Here is small bot demonstrates the problem:
import asyncio
from telebot.async_telebot import AsyncTeleBot
TOKEN = '**********'
bot = AsyncTeleBot(TOKEN)
@bot.message_handler(commands=['id'])
async def id_command(message):
return await bot.reply_to(message, text=f'Your id: {message.chat.id}')
@bot.message_handler(content_types=['photo'])
async def photo_handler(message):
file_id = message.photo[-1].file_id
file_info = await bot.get_file(file_id)
# This download method causes:
# Aiohttp ClientError: ClientOSError and then
# Request timeout. Request: .... and then
# Infinity polling: polling exited
# on the next message
_file = await bot.download_file(file_info.file_path)
return await bot.reply_to(message, f'Path: {file_info.file_path}; Length:{len(_file)}' )
if __name__ == '__main__':
loop = asyncio.new_event_loop()
# Not recovering with infinity_polling: await self._process_polling(non_stop=False....
# Version 4.6.0 recovering after Aiohttp ClientError
# Version 4.6.1 and 4.7.0 not recovering
loop.create_task(bot.infinity_polling())
# Recovering:
# loop.create_task(bot.polling(non_stop=True))
loop.run_forever()
# The scenario:
# - bot is run
# - send /id command and get reply
# - send any image file and get the filename and file length
# - send /id and get polling exited with:
# (asyncio_helper.py:80 MainThread) ERROR - TeleBot: "Aiohttp ClientError: ClientOSError"
# (async_telebot.py:317 MainThread) ERROR - TeleBot: "Request timeout. Request: method=get url=getUpdates params=<aiohttp.formdata.FormData object at 0x0000025A91E391E0> files=None request_timeout=None"
# (async_telebot.py:276 MainThread) ERROR - TeleBot: "Infinity polling: polling exited"
# (async_telebot.py:278 MainThread) ERROR - TeleBot: "Break infinity polling"
coder2020official commented
Your os?
You were supposed to answer to this questions.
I think this might happen due to file rights
coder2020official commented
pass non_stop=True to continue the work of the polling
coder2020official commented
Btw, you should create an issue on official repo, not here