Telegram video sending - increase timeout?

Is it possible to modify the timeout for sending videos in Telegram? I find they often time out with:
Error sending file: urllib3 HTTPError (‘Connection aborted.’, timeout(‘The write operation timed out’,)).

1 Like

Hi, I have the same problem for video upload, did you found the solution ?

Unfortunately not - eventually stopped using the Send Video feature.

Same problem here:

2019-10-13 20:53:12 ERROR (SyncWorker_13) [homeassistant.components.telegram_bot] Error sending file: urllib3 HTTPError ('Connection aborted.', timeout('The write operation timed out')). Args: (93471990, <_io.BufferedReader name='/config/www/tmp/test.mp4'>), kwargs: {'caption': 'This is a test', 'parse_mode': 'Markdown', 'disable_notification': False, 'disable_web_page_preview': None, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}

Try to modify the file " bot.py " line 637. Change 20 to 200.

    def send_video(self,
                   chat_id,
                   video,
                   duration=None,
                   caption=None,
                   disable_notification=False,
                   reply_to_message_id=None,
                   reply_markup=None,
                   timeout=200,
                   width=None,
                   height=None,
                   parse_mode=None,
                   supports_streaming=None,
                   thumb=None,
                   **kwargs):

For my raspberry pi 3 raspian buster the location of that file is:
/srv/homeassistant/lib/python3.7/site-packages/telegram/bot.py

I hope it’s helpful!

1 Like

Hi @methus,
WHile looking with the File Editor addon, it seems my srv folder is empty. I am running Hassio directly on a rapsberry 4. Any clue how to locate bot.py?

Sorry, I don’t have Hassio so I don’t know the structure of the folder. However I think that the last part of the path is the same: …lib/python3.7/site-packages/telegram/bot.py (or python3.8) Try to navigate in the raspberry folder until you find “lib” or “pythonX.X” or “site-packages”. Sorry If I can’t help you more…

Thanks! I found the Python folder but not the Telegram one. Here is where I found the Python folder: /usr/lib/python3.8/site-packages

I think you find the wrong path.
Try to use this command in a raspberry terminal:
find / -name bot.py
This will report you a list of all the file with the name “bot.py”
If you are lucky you will find the right path.
I hope it can help you.

Mmh naive question for you @metus, how can I do that with Hassio please?

I’m really sorry but I’m noob too… I don’t know about Hassio… I learn on my raspberry installing Home assistant in virtual env… And I navigate the installation folder using ssh (software bitvise SSH or putty) from another pc…so I know nothing about config and structure folder of Hassio. A lot of people told me that Hassio is more user friendly but you can not do everything … Sorry if I can help you…

telegram_bot.send_video service has optional timeout attribute.
Description:

Timeout for send video. Will help with timeout errors (poor internet connection, etc)

So, you can set high timeout if you want to get less such errors. The part of the config may look like

    - service: telegram_bot.send_video
      data_template:
        target:
         - !secret garaj_chat_id
        file: "/config/www/video_captures/garaj.mp4"
        timeout: 100