Telegram notification recently buggy

Since I installed the latest HASS version I notice the telegram notification often doesn’t work and these are the errors:

17-02-10 23:10:55 ERROR (Thread-5) [homeassistant.components.notify.telegram] Error sending message
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 386, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 382, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.4/ssl.py", line 745, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.4/ssl.py", line 617, in read
    v = self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/telegram/utils/request.py", line 132, in _request_wrapper
    resp = self._con_pool.request(*args, **kwargs)
  File "/home/homeassistant/.homeassistant/deps/urllib3/request.py", line 70, in request
    **urlopen_kw)
  File "/home/homeassistant/.homeassistant/deps/urllib3/request.py", line 148, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/home/homeassistant/.homeassistant/deps/urllib3/poolmanager.py", line 244, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/homeassistant/.homeassistant/deps/urllib3/util/retry.py", line 347, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/homeassistant/.homeassistant/deps/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 386, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 382, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.4/ssl.py", line 745, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.4/ssl.py", line 617, in read
    v = self._sslobj.read(len, buffer)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/notify/telegram.py", line 122, in send_message
    parse_mode=parse_mode)
  File "/home/homeassistant/.homeassistant/deps/telegram/bot.py", line 125, in decorator
    result = func(self, *args, **kwargs)
  File "/home/homeassistant/.homeassistant/deps/telegram/bot.py", line 151, in decorator
    result = self._request.post(url, data, timeout=kwargs.get('timeout'))
  File "/home/homeassistant/.homeassistant/deps/telegram/utils/request.py", line 207, in post
    **urlopen_kwargs)
  File "/home/homeassistant/.homeassistant/deps/telegram/utils/request.py", line 138, in _request_wrapper
    raise NetworkError('urllib3 HTTPError {0}'.format(error))
telegram.error.NetworkError: urllib3 HTTPError ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

Any idea what it might be?

I get those as well. Although I usually still get the messages (which kind of doesen’t make sense). Today was the first time a message was actually not delivered where I would have actually wanted to be informed (my alarm system wasn’t armed when I left the house).

It’s a real pity because I use it for alarm notification and it worked flawless until recently :frowning:

So no one that can solve this?
I hate an unreliable notification service :frowning:

I have the same problem.
It seems happens first notification of the day or after a long time after last successful notification sent

It’s a shame that components over time suddenly start having problems.

Anyone has a solution for this?

If anyone has any idea how to fix this issue that would be great.
Currently not all Telegram notifications are send :(. So it’s unreliable.

Am I the only one with this issue and is not happy with it?

I have downgraded back to 0.38.4

sudo pip3 install --upgrade homeassistant==0.38.4

And then it works perfectly?

I don’t want to downgrade actually as I use new things that came with newer versions.

Hopefully someone can fix this some day for the newer versions.

nothing is perfect. but I face less problems in 0.38.4.

Don’t know if it got worse with 0.39 because I stuck to 0.38.4 as well. But even with 0.38.4 some messages don’t arrive. So for important, simple textual messages I’m now probably switching to the Automate notify platform. It’s free, so worth a try.

Until Telegram is reliable again I’m using Twitter. Created a dummy HASS user you can send DM’s to my own Twitter account.
It’s a shame so many new things and fixes in new versions but nothing about this Telegram issue (or the chromecast issue that’s there for months already)

Still not fixed with 0.40.1.

I guess the problem is, that’s it’s not really easy to reproduce. For me it only happens occasionally. And some people around here maybe don’t even notice it at all. Maybe if failed notifications would popup persistent notifictions in the UI this would get more attention.

I can’t get any messages to send at all in Telegram on 0.38.3. The service gets called but nothing happens. I am getting urllib3 errors in my logs, but not the same as the ones here.

here also problem since 0.39

17-04-26 09:09:08 ERROR (Thread-7) [homeassistant.components.notify.telegram] Error sending message
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/socket.py", line 732, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connection.py", line 284, in connect
    conn = self._new_conn()
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x10fd82208>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/telegram/utils/request.py", line 132, in _request_wrapper
    resp = self._con_pool.request(*args, **kwargs)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/request.py", line 70, in request
    **urlopen_kw)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/request.py", line 148, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/poolmanager.py", line 244, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot........./sendMessage (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10fd82208>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/homeassistant/components/notify/telegram.py", line 127, in send_message
    parse_mode=parse_mode)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/telegram/bot.py", line 125, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/telegram/bot.py", line 151, in decorator
    result = self._request.post(url, data, timeout=kwargs.get('timeout'))
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/telegram/utils/request.py", line 207, in post
    **urlopen_kwargs)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/telegram/utils/request.py", line 138, in _request_wrapper
    raise NetworkError('urllib3 HTTPError {0}'.format(error))
telegram.error.NetworkError: urllib3 HTTPError HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot......../sendMessage (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10fd82208>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))

If you encounter issue’s when HASS is trying to start the Telegram component this might be a solution for you: https://github.com/home-assistant/home-assistant/issues/7298#issuecomment-297250734

Regarding the often not sending of notifications I don’t think there is a solution yet :(.
It’s unreliable and thus I’m using Twitter for my alarm notifications.

Version 0.45 still having Telegram issues:

2017-05-23 19:14:38 ERROR (Thread-9) [homeassistant.components.telegram_bot] Error sending message
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 386, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 382, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.4/ssl.py", line 745, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.4/ssl.py", line 617, in read
    v = self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/telegram/utils/request.py", line 132, in _request_wrapper
    resp = self._con_pool.request(*args, **kwargs)
  File "/home/homeassistant/.homeassistant/deps/urllib3/request.py", line 70, in request
    **urlopen_kw)
  File "/home/homeassistant/.homeassistant/deps/urllib3/request.py", line 148, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/home/homeassistant/.homeassistant/deps/urllib3/poolmanager.py", line 244, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/homeassistant/.homeassistant/deps/urllib3/util/retry.py", line 347, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/homeassistant/.homeassistant/deps/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 386, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/homeassistant/.homeassistant/deps/urllib3/connectionpool.py", line 382, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.4/ssl.py", line 745, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.4/ssl.py", line 617, in read
    v = self._sslobj.read(len, buffer)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/telegram_bot/__init__.py", line 377, in _send_msg
    out = func_send(*args_rep, **kwargs_rep)
  File "/home/homeassistant/.homeassistant/deps/telegram/bot.py", line 125, in decorator
    result = func(self, *args, **kwargs)
  File "/home/homeassistant/.homeassistant/deps/telegram/bot.py", line 151, in decorator
    result = self._request.post(url, data, timeout=kwargs.get('timeout'))
  File "/home/homeassistant/.homeassistant/deps/telegram/utils/request.py", line 207, in post
    **urlopen_kwargs)
  File "/home/homeassistant/.homeassistant/deps/telegram/utils/request.py", line 138, in _request_wrapper
    raise NetworkError('urllib3 HTTPError {0}'.format(error))
telegram.error.NetworkError: urllib3 HTTPError ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

Here also still the problem of sometimes not sending a text

2017-05-30 16:58:30 ERROR (<concurrent.futures.thread.ThreadPoolExecutor object at 0x1072ee7b8>_7) [homeassistant.components.telegram_bot] Error sending message
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 743, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 284, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x1096f78d0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 132, in _request_wrapper
    resp = self._con_pool.request(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/urllib3/request.py", line 70, in request
    **urlopen_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/request.py", line 148, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/poolmanager.py", line 244, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
    urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot******I/sendMessage (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x1096f78d0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/site-packages/homeassistant/components/telegram_bot/__init__.py", line 378, in _send_msg
        out = func_send(*args_rep, **kwargs_rep)
      File "/usr/local/lib/python3.6/site-packages/telegram/bot.py", line 125, in decorator
        result = func(self, *args, **kwargs)
      File "/usr/local/lib/python3.6/site-packages/telegram/bot.py", line 151, in decorator
        result = self._request.post(url, data, timeout=kwargs.get('timeout'))
      File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 207, in post
        **urlopen_kwargs)
      File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 138, in _request_wrapper
        raise NetworkError('urllib3 HTTPError {0}'.format(error))
    telegram.error.NetworkError: urllib3 HTTPError HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot*****/sendMessage (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x1096f78d0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))