it gives me the following error
ERROR (SyncWorker_13) [homeassistant.components.telegram_bot] Error sending file: urllib3 HTTPError ('Connection aborted.', timeout('The write operation timed out',))
until know it worked without problem with files up to 15mb then suddendly and without code changes on my side it gives me this error if the files is bigger than 10mb.
Is there a way to modify the timeout time?
@Azertooth Please use the issue template that is shown when creating an issue. Thanks! 👍
I also have this issue, even for small files.
Home Assistant release with the issue:
0.100.3
Last working Home Assistant release (if known):
Operating environment (Hass.io/Docker/Windows/etc.):
Hassio, RPi
Integration:
https://www.home-assistant.io/integrations/telegram/
Description of problem:
When sending video files from Hassio's www directory to Telegram via bot, usually (but not always) this error appears in the log:
Error sending file: urllib3 HTTPError ('Connection aborted.', timeout('The write operation timed out')). Args: (966495836, <_io.BufferedReader name='/config/www/foo/bar.mp4'>), kwargs: {'caption': None, 'parse_mode': 'Markdown', 'disable_notification': False, 'disable_web_page_preview': None, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}
The video is not sent.
See also https://github.com/home-assistant/home-assistant/issues/14316
Problem-relevant configuration.yaml
entries and (fill out even if it seems unimportant):
- service: notify.telegram_cameras
data_template:
message: ""
data:
video:
- file: >
{{ "/config/www/foo/" + trigger.event.data.filename }}
caption: >
Bar {{trigger.event.data.filename.split("_")[1]}} New Video
Additional information:
The last file it failed on was 9.3MB.
I don't think it's necessarily the size of the file, except that large files take longer so more likely to timeout.
A slow network connection might cause a timeout on a small file.
I'd like to highlight this bit of the error:
'timeout': None
On the above referenced issue, shivampip mentioned that the timeout needs setting to 1000.
I have tried that on the services page, but it seems to be ignored.
Same problem here.
Should I create a new issue based on my post above, as this one might be ignored due to not being started correctly?
i don't think it will make a difference but we can try to gain attention that way, if you do please link the new issue here
Da: t9001 notifications@github.com
Inviato: venerdì 22 novembre 2019 00:20
A: home-assistant/home-assistant
Cc: Azertooth; Mention
Oggetto: Re: [home-assistant/home-assistant] Telegram bot: timeouts when sending video files >10mb (#26498)
Should I create a new issue based on my post above, as this one might be ignored due to not being started correctly?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Same problem here
_ERROR (SyncWorker_3) [homeassistant.components.telegram_bot]
Error sending file: urllib3 HTTPError ('Connection aborted.', timeout('The writ
e operation timed out')). Args: (123456, <_io.BufferedReader name='/mijia/xiaom
i_camera_videos/7x3kd7v0rk441.mp4'>), kwargs: {'caption': 'Vídeo', 'parse_mode':
'Markdown', 'disable_notification': False, 'disable_web_page_preview': None, 'r
eply_to_message_id': None, 'reply_markup': None, 'timeout': None}_
Seems that backend actually supports sending files with custom timeouts
https://python-telegram-bot.readthedocs.io/en/stable/telegram.bot.html#telegram.Bot.send_document
Would it be possible to implement this in HA?
getting this problem too
send video files <3mb but getting a problem due to slow connection to internet(<6Mbit/s on upload)
but files <1.5mb sends correctly ☹
so, i fix it hard:
copy all this files
to /config/custom_components/telegram_bot/ (create this folder if not exist)
and replace this lines in __init__.py
:
if CONF_TIMEOUT in data:
params[CONF_TIMEOUT] = data[CONF_TIMEOUT]
To this (set timeout hardcode):
params[CONF_TIMEOUT] = 1000
this solved the problem
Many hanks @Konsts!
Could you submit this change upstream?
so, i fix it hard:
copy all this files
to /config/custom_components/telegram_bot/ (create this folder if not exist)
and replace this lines in__init__.py
:if CONF_TIMEOUT in data: params[CONF_TIMEOUT] = data[CONF_TIMEOUT]
To this (set timeout hardcode):
params[CONF_TIMEOUT] = 1000
this solved the problem
shouldn't the folder be named telegram_bot_custom instead?
Many hanks @Konsts!
Could you submit this change upstream?
ok, i will create pull request
so, i fix it hard:
copy all this files
to /config/custom_components/telegram_bot/ (create this folder if not exist)
and replace this lines in__init__.py
:if CONF_TIMEOUT in data: params[CONF_TIMEOUT] = data[CONF_TIMEOUT]
To this (set timeout hardcode):
params[CONF_TIMEOUT] = 1000
this solved the problem
It doesn´t work for me....
2020-01-28 16:14:14 ERROR (SyncWorker_0) [custom_components.telegram_bot] Error sending file: urllib3 HTTPError ('Connection aborted.', timeout('The write operation timed out')). Args: (-12456789, <_io.BufferedReader name='/config/www/snapshot/salon.mp4'>), kwargs: {'caption': 'Alguien entra en casa', 'parse_mode': 'Markdown', 'disable_notification': False, 'disable_web_page_preview': None, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}
salon.mp4 has 1.027KB and doesn't send... It works for me when it weighs no more than 400KB
@Chimete maybe try increasing the timeout
@Konsts The truth is that I don't know how much to increase or what that increase does ... double? 2000?
@Chimete why not? try it!
@Konts Do you know what that increase does?
@Chimete
timeout (int | float, optional) – If this value is specified, use it as the read timeout from the server (instead of the one specified during creation of the connection pool).
@Konsts
params[CONF_TIMEOUT] = 2000
doesn't works...
Thanks
Is working for somebody? (sorry for my bad english)
@Chimete what is your HA version? you copy all files to /custom_components/telegram_bot/ ?
@Chimete what is your HA version? you copy all files to /custom_components/telegram_bot/ ?
Yes
/docker/Homeassistant/custom_components/telegram_bot
with (root/root)
I did it all over again and it already works. Thank you very much
Copy the files, and it worked again!
Thank you very much for the help!
PS: I had downloaded the files with wget and they got down in a corrupt way, that's why it hadn't worked for me.
PD2: Sorry for my English.
it still not work for me
if CONF_TIMEOUT in data:
params[CONF_TIMEOUT] = data[CONF_TIMEOUT]
in
if CONF_TIMEOUT in data:
params[CONF_TIMEOUT] = 1000
but it still gives me timeout error
edit: i increased it to 10000 and it works now!
this make me think that it's not the exact size of the files per se that matters but the upload capacity in that exact moment: i was receving correctly the video on telegram 1/6 of the times roughly, so sometimes it was capable to send it but most of the time not. Now with this increase it sends the video every time
Thank you guys, i was fighting this for almost a year, what an amazing community <3
HI....you only have to change
Hi,
I see the change in #31379 and it works great.
For telegram_bot.send_video
Doesn't work for notify.example_telegram_chat
I have to use notify....
to send a video in a particular case.
I think it's because of an improbably long URL.
Using telegram_bot.send_video
I get:
Can't send file with kwargs: {'data': {'caption': 'Garage 03-22 17:18', 'url': 'https://arlos3-prod-z2.s3.amazonaws.com/xxxxxxxx_xxxx_xxxx_xxxx_xxxxxxxxxxxx/111-1111111/XXXXXXXXXXXXX/recordings/1111111111111.mp4?AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXX&Expires=1111111111&Signature=XXX%2FXXXXXXXXX%2FXXXXXXXXXXXXX%3D', 'target': '-111111111', 'timeout': 1000}}
Possible to add the custom timeout option to the notify...
parameters?
I can see from the above error that the default is now 1000, but I still get timeouts sometimes.
When I try to add the timeout parameter to notify...
I get:
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['timeout']
Many thanks :)
@t9001 create new issue for this
@t9001 create new issue for this
Since i had adjusted this (not too much, as Telegram only allows 50MB files anyway) im getting a lot of connection errors:
Logger: telegram.vendor.ptb_urllib3.urllib3.connectionpool
Source: /usr/local/lib/python3.7/site-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py:690
First occurred: March 25, 2020, 7:59:02 AM (598 occurrences)
Last logged: 6:18:41 AM
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0a0567a190>: Failed to establish a new connection: [Errno -3] Try again')': /bot521998571:AAGWQAU-mxxWyixkolbUIMaApJVAXI1r4mA/getUpdates
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0a04837c50>: Failed to establish a new connection: [Errno -3] Try again')': /bot521998571:AAGWQAU-mxxWyixkolbUIMaApJVAXI1r4mA/getUpdates
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x7f09fce74750>: Failed to establish a new connection: [Errno -3] Try again')': /bot521998571:AAGWQAU-mxxWyixkolbUIMaApJVAXI1r4mA/getUpdates
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0a047688d0>: Failed to establish a new connection: [Errno -3] Try again')': /bot521998571:AAGWQAU-mxxWyixkolbUIMaApJVAXI1r4mA/getUpdates
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0a046c3b10>: Failed to establish a new connection: [Errno -3] Try again')': /bot521998571:AAGWQAU-mxxWyixkolbUIMaApJVAXI1r4mA/getUpdates
No need to copy any files, simply use this construct:
action:
- service: notify.telegram_bot
data:
title: Your title
message: "Your message"
data:
video:
- file: '/path/to/your.mp4'
timeout: 180 # set any timeout
Most helpful comment
so, i fix it hard:
copy all this files
to /config/custom_components/telegram_bot/ (create this folder if not exist)
and replace this lines in
__init__.py
:To this (set timeout hardcode):
this solved the problem