Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bot.download_file causes Aiohttp ClientError: ClientOSError #1

Open
yudytskiy opened this issue Sep 7, 2022 · 3 comments
Open

bot.download_file causes Aiohttp ClientError: ClientOSError #1

yudytskiy opened this issue Sep 7, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@yudytskiy
Copy link

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
Copy link
Owner

coder2020official commented Sep 7, 2022

Your os?
You were supposed to answer to this questions.
I think this might happen due to file rights

@coder2020official
Copy link
Owner

pass non_stop=True to continue the work of the polling

@coder2020official coder2020official added the bug Something isn't working label Sep 7, 2022
@coder2020official
Copy link
Owner

Btw, you should create an issue on official repo, not here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants