sighmon / balena-enviro-plus

Enviro-plus environment sensor deployment to Raspberry Pi via Balena IoT platform
9 stars 7 forks source link

Connection dropped out to influx. #4

Closed shleeable closed 4 years ago

shleeable commented 4 years ago

2020-04-06 12:45:13.183 INFO Luftdaten response: OK 2020-04-06 12:45:47.382 INFO Luftdaten response: OK 2020-04-06 12:46:27.460 WARNING Exception sending to Luftdaten: HTTPSConnectionPool(host='api.luftdaten.info', port=443): Max retries exceeded with url: /v1/push-sensor-data/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb43c8490>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')) 2020-04-06 12:47:07.593 WARNING Exception sending to Luftdaten: HTTPSConnectionPool(host='api.luftdaten.info', port=443): Max retries exceeded with url: /v1/push-sensor-data/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb5553b10>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')) 2020-04-06 12:47:40.751 INFO Luftdaten response: OK Exception in thread Thread-2: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen chunked=chunked, File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 416, in _make_request httplib_response = conn.getresponse() File "/usr/local/lib/python3.7/http/client.py", line 1336, in getresponse response.begin() File "/usr/local/lib/python3.7/http/client.py", line 306, in begin version, status, reason = self._read_status() File "/usr/local/lib/python3.7/http/client.py", line 267, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/local/lib/python3.7/socket.py", line 589, in readinto return self._sock.recv_into(b) File "/usr/local/lib/python3.7/ssl.py", line 1071, in recv_into return self.read(nbytes, buffer) File "/usr/local/lib/python3.7/ssl.py", line 929, in read return 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 "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner self.run() File "/usr/local/lib/python3.7/threading.py", line 870, in run self._target(*self._args, self._kwargs) File "enviroplus_exporter.py", line 169, in post_to_influxdb influxdb_api.write(bucket=INFLUXDB_BUCKET, record=data_points) File "/usr/local/lib/python3.7/site-packages/influxdb_client/client/write_api.py", line 218, in write return self._post_write(_async_req, bucket, org, final_string, write_precision) File "/usr/local/lib/python3.7/site-packages/influxdb_client/client/write_api.py", line 295, in _post_write content_type="text/plain; charset=utf-8") File "/usr/local/lib/python3.7/site-packages/influxdb_client/service/write_service.py", line 62, in post_write (data) = self.post_write_with_http_info(org, bucket, body, kwargs) # noqa: E501 File "/usr/local/lib/python3.7/site-packages/influxdb_client/service/write_service.py", line 175, in post_write_with_http_info collection_formats=collection_formats) File "/usr/local/lib/python3.7/site-packages/influxdb_client/api_client.py", line 339, in call_api _preload_content, _request_timeout) File "/usr/local/lib/python3.7/site-packages/influxdb_client/api_client.py", line 170, in __call_api _request_timeout=_request_timeout) File "/usr/local/lib/python3.7/site-packages/influxdb_client/api_client.py", line 382, in request body=body) File "/usr/local/lib/python3.7/site-packages/influxdb_client/rest.py", line 278, in POST body=body) File "/usr/local/lib/python3.7/site-packages/influxdb_client/rest.py", line 201, in request headers=headers) File "/usr/local/lib/python3.7/site-packages/urllib3/request.py", line 80, in request method, url, fields=fields, headers=headers, urlopen_kw File "/usr/local/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body return self.urlopen(method, url, extra_kw) File "/usr/local/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 400, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 734, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen chunked=chunked, File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 416, in _make_request httplib_response = conn.getresponse() File "/usr/local/lib/python3.7/http/client.py", line 1336, in getresponse response.begin() File "/usr/local/lib/python3.7/http/client.py", line 306, in begin version, status, reason = self._read_status() File "/usr/local/lib/python3.7/http/client.py", line 267, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/local/lib/python3.7/socket.py", line 589, in readinto return self._sock.recv_into(b) File "/usr/local/lib/python3.7/ssl.py", line 1071, in recv_into return self.read(nbytes, buffer) File "/usr/local/lib/python3.7/ssl.py", line 929, in read return self._sslobj.read(len, buffer) urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) 2020-04-06 12:48:13.813 INFO Luftdaten response: OK 2020-04-06 12:48:47.007 INFO Luftdaten response: OK 2020-04-06 12:49:20.275 INFO Luftdaten response: OK 2020-04-06 12:49:53.380 INFO Luftdaten response: OK 2020-04-06 12:50:26.445 INFO Luftdaten response: OK

sighmon commented 4 years ago

@shleeable Nice thanks! I forgot to catch InfluxDB posts, was only catching Luftdaten posts.

I've now added a DEBUG env var which only shows logging.info if DEBUG=true.

To pull the new changes on your box:

# stash your Dockerfile edits
git stash
# pull new changes and init submodule again
git pull
git submodule update --init
# pop back your Dockerfile changes
git stash pop
# you might want to set DEBUG=false to only see warnings/errors
# then rebuild the container
docker build -t sighmon/enviroplus_exporter:v2 .
# stop your old one, and then run the new one
docker run -d --privileged -p 8000:8000 sighmon/enviroplus_exporter:v2
shleeable commented 4 years ago

Updated, and it looks good.

Thanks!