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

InfluxDB sensor does not recover if InfluxDB was unreachable during HA startup #26493

Closed
schwma opened this issue Sep 7, 2019 · 5 comments
Closed

Comments

@schwma
Copy link

schwma commented Sep 7, 2019

Home Assistant release with the issue:

0.98.4

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.):

Docker

Component/platform:

InfluxDB

Description of problem:
Currently, if the InfluxDB server is unreachable while Home Assistant is starting up, the sensor badges do not show up in my auto-gen Lovelace UI. After failing to reach InfluxDB during startup, Home Assistant will not recover the InfluxDB sensor even if the InfluxDB server is reachable again. I personally would expect Home Assistant to periodically retry to reconnect to the InfluxDB server.

This issue is similar to #18094, but it concerns polling sensor data from InfluxDB rather than persisting data. Might be the same issue as #25038, but could be different since connection can't be established at startup.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

influxdb:

sensor:
  - platform: influxdb
    host: myhost
    queries:
      - name: Temperature
        unit_of_measurement: °C
        value_template: '{{ value | round(1) }}'
        group_function: last
        where: '"location" = ''inside'''
        measurement: '"weather_data"'
        field: temperature
        database: weatherstation

Traceback (if applicable):

2019-09-07 14:13:35 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform influxdb
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1290, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1239, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 183, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7ffaf5f9b610>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='myhost', port=8086): Max retries exceeded with url: /query?q=SHOW+SERIES+LIMIT+1%3B&db=weatherstation (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ffaf5f9b610>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/influxdb/sensor.py", line 85, in setup_platform
    sensor = InfluxSensor(hass, influx_conf, query)
  File "/usr/src/homeassistant/homeassistant/components/influxdb/sensor.py", line 124, in __init__
    influx.query("SHOW SERIES LIMIT 1;")
  File "/usr/local/lib/python3.7/site-packages/influxdb/client.py", line 416, in query
    expected_response_code=expected_response_code
  File "/usr/local/lib/python3.7/site-packages/influxdb/client.py", line 267, in request
    timeout=self._timeout
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='myhost', port=8086): Max retries exceeded with url: /query?q=SHOW+SERIES+LIMIT+1%3B&db=weatherstation (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ffaf5f9b610>: Failed to establish a new connection: [Errno 111] Connection refused'))

Additional information:

@probot-home-assistant
Copy link

Hey there @fabaff, mind taking a look at this issue as its been labeled with a integration (influxdb) you are listed as a codeowner for? Thanks!

@stale
Copy link

stale bot commented Dec 6, 2019

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 6, 2019
@stale stale bot closed this as completed Dec 13, 2019
@Stampede10343
Copy link

Anyone else seeing this issue? I constantly run into this when restarting HA, I always need to start up InfluxDb and let it initialize, then start/restart HA.

I tried looking at other sensors to see if they somehow re-connect if they fail initial connection but didn't come up with anything.

@SzymonZy
Copy link

SzymonZy commented May 21, 2020

I have the same issue. Moved to hassio from separate onpremise installation and it sux. Any solution for that? It should be reopened. Homeassistant container should wait unitl influx container is up.

@Stampede10343
Copy link

I switched versions of InfluxDb I haven't had the issue since, not sure if its related but so far so good the last couple months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants