jertel / vuegraf

Populate metrics from your Emporia Vue energy monitoring devices into an InfluxDB
MIT License
166 stars 53 forks source link

Emporia connection or local container issue? #33

Closed jbird526 closed 3 years ago

jbird526 commented 3 years ago

Anyone else receiving a similar issue in their vuegraf container? I have been trying to debug if this is an issue with connecting to Emporia or my InfluxDB container. Error viewed in Docker Desktop for Mac. Have been trying to create a docker-compose file to bring up all containers so no need to run the individual commands.

`Traceback (most recent call last):

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen

httplib_response = self._make_request(

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 445, in _make_request

six.raise_from(e, None)

File "", line 3, in raise_from

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 440, in _make_request

httplib_response = conn.getresponse()

File "/usr/local/lib/python3.9/http/client.py", line 1347, in getresponse

response.begin()

File "/usr/local/lib/python3.9/http/client.py", line 307, in begin

version, status, reason = self._read_status()

File "/usr/local/lib/python3.9/http/client.py", line 276, in _read_status

raise RemoteDisconnected("Remote end closed connection without"

http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send

resp = conn.urlopen(

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen

retries = retries.increment(

File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 531, in increment

raise six.reraise(type(error), error, _stacktrace)

File "/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py", line 734, in reraise

raise value.with_traceback(tb)

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen

httplib_response = self._make_request(

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 445, in _make_request

six.raise_from(e, None)

File "", line 3, in raise_from

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 440, in _make_request

httplib_response = conn.getresponse()

File "/usr/local/lib/python3.9/http/client.py", line 1347, in getresponse

response.begin()

File "/usr/local/lib/python3.9/http/client.py", line 307, in begin

version, status, reason = self._read_status()

File "/usr/local/lib/python3.9/http/client.py", line 276, in _read_status

raise RemoteDisconnected("Remote end closed connection without"

urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/opt/vuegraf/vuegraf.py", line 28, in

influx.create_database(config['influxDb']['database'])

File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 746, in create_database

self.query("CREATE DATABASE {0}".format(quote_ident(dbname)),

File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 521, in query

response = self.request(

File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 332, in request

response = self._session.request(

File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request

resp = self.send(prep, **send_kwargs)

File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send

r = adapter.send(request, **kwargs)

File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 498, in send

raise ConnectionError(err, request=request)

requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))`

jertel commented 3 years ago

Make sure your influxDb container's host/ip is accessible from the Vuegraf container. You can exec into the vuegraf container to run some pings or curls to the influxdb to ensure you can connect to that port. If the Vuegraf container is in a crash loop you might need to override the vuegraf entrypoint to run a long sleep. Ex: bash -c "sleep 300". Or launch an alpine container onto the same dockernet.

jbird526 commented 3 years ago

Wanted to follow up on the issue that I first posted. In order to narrow down the exact issue I was receiving, I ended up running the vuegraf.py in VS Code and setting breakpoints. Was finding that on the following I was receiving a 401.

influx.create_database(config['influxDb']['database'])

After scratching my head for bit and investigation I realized the Infuxdb v2 does not by default set authentication to false. Since I am just testing this out locally, I am not concerned about securing the DB.

I ended up creating a docker-compose file with the following and now no authentication issue thrown. I set the InfluxDB image version explicitly to image: influxdb:1.8.4-alpine instead of image: influxdb

Also in the vuegraf: config it was necessary to add restart: always or vuegraf was calling InfluxDB too early . A wait could be added to below vuegraf-run.sh but this is simple and does work.

version: "3.5" services: influxdb: image: influxdb:1.8.4-alpine container_name: influxdb ports:

Script to run the docker-compose. Each time you run the script it will bring down any previous containers before starting up. vuegraf-run.sh `set -e

echo "Bringing up influxdb, grafana, vuegraf" docker-compose down && docker-compose -f docker-compose.yaml build --pull && docker-compose -f docker-compose.yaml up -d

echo "Done"`

vuegraf.json { "influxDb": { "host": "host.docker.internal", "port": 8086, "database": "vue", "reset": false }, "accounts": [ { "name": "VUE", "email": "*****", "password": "*****", "devices": [ { "name": "Right Panel", "channels": [ "Aquariums", "Fridge", "Microwave", "Furnace", "Range", "Dryer", "Garage", "First Floor" ] } ] } ] }

jbird526 commented 3 years ago

Closing issue as it was all on my end with configuration updates needed.

jertel commented 3 years ago

That docker compose file would be a good addition to the repo, for others that prefer to use compose instead of manual launching. If you submit it as a PR and put a note in the README about it I'll get it merged in.