AvansETI / SmartSensor

SmartSensor: a sensor to be used as sensor and actuator within existing buildings.
GNU General Public License v3.0
1 stars 2 forks source link

SmartNetwork crashes when Influx database is not available #12

Open macsnoeren opened 2 years ago

macsnoeren commented 2 years ago
0|SmartNet | Traceback (most recent call last):
0|SmartNet |   File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
0|SmartNet |     six.raise_from(e, None)
0|SmartNet |   File "<string>", line 3, in raise_from
0|SmartNet |   File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
0|SmartNet |     httplib_response = conn.getresponse()
0|SmartNet |   File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
0|SmartNet |     response.begin()
0|SmartNet |   File "/usr/lib/python3.8/http/client.py", line 316, in begin
0|SmartNet |     version, status, reason = self._read_status()
0|SmartNet |   File "/usr/lib/python3.8/http/client.py", line 277, in _read_status
0|SmartNet |     line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
0|SmartNet |   File "/usr/lib/python3.8/socket.py", line 669, in readinto
0|SmartNet |     return self._sock.recv_into(b)
0|SmartNet | socket.timeout: timed out
0|SmartNet |
0|SmartNet | During handling of the above exception, another exception occurred:
0|SmartNet |
0|SmartNet | Traceback (most recent call last):
0|SmartNet |   File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
0|SmartNet |     self.run()
0|SmartNet |   File "/usr/lib/python3.8/threading.py", line 870, in run
0|SmartNet |     self._target(*self._args, **self._kwargs)
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3591, in _thread_main
0|SmartNet |     self.loop_forever(retry_first_connection=True)
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1756, in loop_forever
0|SmartNet |     rc = self._loop(timeout)
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1164, in _loop
0|SmartNet |     rc = self.loop_read()
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1556, in loop_read
0|SmartNet |     rc = self._packet_read()
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2439, in _packet_read
0|SmartNet |     rc = self._packet_handle()
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3033, in _packet_handle
0|SmartNet |     return self._handle_publish()
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3327, in _handle_publish
0|SmartNet |     self._handle_on_message(message)
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3570, in _handle_on_message
0|SmartNet |     on_message(self, self._userdata, message)
0|SmartNet |   File "/home/maurice/SmartSensor/SmartNetwork/smartnetwork/smartnetwork/smartnetwork.py", line 79, in <lambda>
0|SmartNet |     self.mqtt.on_message    = lambda client, userdata, msg:       self.mqtt_on_message(client, userdata, msg)
0|SmartNet |   File "/home/maurice/SmartSensor/SmartNetwork/smartnetwork/smartnetwork/smartnetwork.py", line 119, in mqtt_on_message
0|SmartNet |     self.process_node_data(plJson)
0|SmartNet |   File "/home/maurice/SmartSensor/SmartNetwork/smartnetwork/smartnetwork/smartnetwork.py", line 231, in process_node_data
0|SmartNet |     node = self.get_node_from_id(data["id"])
0|SmartNet |   File "/home/maurice/SmartSensor/SmartNetwork/smartnetwork/smartnetwork/smartnetwork.py", line 172, in get_node_from_id
0|SmartNet |     records = self.query.query(org=self.org, query=query)
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/client/query_api.py", line 100, in query
0|SmartNet |     response = self._query_api.post_query(org=org, query=self._create_query(query, self.default_dialect, params),
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/service/query_service.py", line 258, in post_query
0|SmartNet |     (data) = self.post_query_with_http_info(**kwargs)  # noqa: E501
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/service/query_service.py", line 338, in post_query_with_http_info
0|SmartNet |     return self.api_client.call_api(
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/api_client.py", line 341, in call_api
0|SmartNet |     return self.__call_api(resource_path, method,
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/api_client.py", line 171, in __call_api
0|SmartNet |     response_data = self.request(
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/api_client.py", line 386, in request
0|SmartNet |     return self.rest_client.POST(url,
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/rest.py", line 304, in POST
0|SmartNet |     return self.request("POST", url,
0|SmartNet |   File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/rest.py", line 183, in request
0|SmartNet |     r = self.pool_manager.request(
0|SmartNet |   File "/usr/lib/python3/dist-packages/urllib3/request.py", line 79, in request
0|SmartNet |     return self.request_encode_body(
0|SmartNet |   File "/usr/lib/python3/dist-packages/urllib3/request.py", line 171, in request_encode_body
0|SmartNet |     return self.urlopen(method, url, **extra_kw)
0|SmartNet |   File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 330, in urlopen
0|SmartNet |     response = conn.urlopen(method, u.request_uri, **kw)
0|SmartNet |   File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
0|SmartNet |     retries = retries.increment(
0|SmartNet |   File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 376, in increment
0|SmartNet |     raise six.reraise(type(error), error, _stacktrace)
0|SmartNet |   File "/usr/lib/python3/dist-packages/six.py", line 703, in reraise
0|SmartNet |     raise value
0|SmartNet |   File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
0|SmartNet |     httplib_response = self._make_request(
0|SmartNet |   File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 423, in _make_request
0|SmartNet |     self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
0|SmartNet |   File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 330, in _raise_timeout
0|SmartNet |     raise ReadTimeoutError(
0|SmartNet | urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=8086): Read timed out. (read timeout=9.999623824842274)
macsnoeren commented 2 years ago

|SmartNet | During handling of the above exception, another exception occurred: 0|SmartNet | 0|SmartNet | Traceback (most recent call last): 0|SmartNet | File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner 0|SmartNet | self.run() 0|SmartNet | File "/usr/lib/python3.8/threading.py", line 870, in run 0|SmartNet | self._target(*self._args, self._kwargs) 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3591, in _thread_main 0|SmartNet | self.loop_forever(retry_first_connection=True) 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1756, in loop_forever 0|SmartNet | rc = self._loop(timeout) 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1164, in _loop 0|SmartNet | rc = self.loop_read() 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1556, in loop_read 0|SmartNet | rc = self._packet_read() 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2439, in _packet_read 0|SmartNet | rc = self._packet_handle() 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3033, in _packet_handle 0|SmartNet | return self._handle_publish() 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3327, in _handle_publish 0|SmartNet | self._handle_on_message(message) 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3570, in _handle_on_message 0|SmartNet | on_message(self, self._userdata, message) 0|SmartNet | File "/home/maurice/SmartSensor/SmartNetwork/smartnetwork/smartnetwork/smartnetwork.py", line 79, in 0|SmartNet | self.mqtt.on_message = lambda client, userdata, msg: self.mqtt_on_message(client, userdata, msg) 0|SmartNet | File "/home/maurice/SmartSensor/SmartNetwork/smartnetwork/smartnetwork/smartnetwork.py", line 119, in mqtt_on_message 0|SmartNet | self.process_node_data(plJson) 0|SmartNet | File "/home/maurice/SmartSensor/SmartNetwork/smartnetwork/smartnetwork/smartnetwork.py", line 231, in process_node_data 0|SmartNet | node = self.get_node_from_id(data["id"]) 0|SmartNet | File "/home/maurice/SmartSensor/SmartNetwork/smartnetwork/smartnetwork/smartnetwork.py", line 172, in get_node_from_id 0|SmartNet | records = self.query.query(org=self.org, query=query) 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/client/query_api.py", line 100, in query 0|SmartNet | response = self._query_api.post_query(org=org, query=self._create_query(query, self.default_dialect, params), 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/service/query_service.py", line 258, in post_query 0|SmartNet | (data) = self.post_query_with_http_info(kwargs) # noqa: E501 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/service/query_service.py", line 338, in post_query_with_http_info 0|SmartNet | return self.api_client.call_api( 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/api_client.py", line 341, in call_api 0|SmartNet | return self.call_api(resource_path, method, 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/api_client.py", line 171, in call_api 0|SmartNet | response_data = self.request( 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/api_client.py", line 386, in request 0|SmartNet | return self.rest_client.POST(url, 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/rest.py", line 304, in POST 0|SmartNet | return self.request("POST", url, 0|SmartNet | File "/home/maurice/.local/lib/python3.8/site-packages/influxdb_client/rest.py", line 183, in request 0|SmartNet | r = self.pool_manager.request( 0|SmartNet | File "/usr/lib/python3/dist-packages/urllib3/request.py", line 79, in request 0|SmartNet | return self.request_encode_body( 0|SmartNet | File "/usr/lib/python3/dist-packages/urllib3/request.py", line 171, in request_encode_body 0|SmartNet | return self.urlopen(method, url, extra_kw) 0|SmartNet | File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 330, in urlopen 0|SmartNet | response = conn.urlopen(method, u.request_uri, kw) 0|SmartNet | File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen 0|SmartNet | retries = retries.increment( 0|SmartNet | File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 376, in increment 0|SmartNet | raise six.reraise(type(error), error, _stacktrace) 0|SmartNet | File "/usr/lib/python3/dist-packages/six.py", line 703, in reraise 0|SmartNet | raise value 0|SmartNet | File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen 0|SmartNet | httplib_response = self._make_request( 0|SmartNet | File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 387, in _make_request 0|SmartNet | conn.request(method, url, **httplib_request_kw) 0|SmartNet | File "/usr/lib/python3.8/http/client.py", line 1256, in request 0|SmartNet | self._send_request(method, url, body, headers, encode_chunked) 0|SmartNet | File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request 0|SmartNet | self.endheaders(body, encode_chunked=encode_chunked) 0|SmartNet | File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders 0|SmartNet | self._send_output(message_body, encode_chunked=encode_chunked) 0|SmartNet | File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output 0|SmartNet | self.send(msg) 0|SmartNet | File "/usr/lib/python3.8/http/client.py", line 951, in send 0|SmartNet | self.connect() 0|SmartNet | File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 187, in connect 0|SmartNet | conn = self._new_conn() 0|SmartNet | File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 171, in _new_conn 0|SmartNet | raise NewConnectionError( 0|SmartNet | urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fe0720dc4f0>: Failed to establish a new connection: [Errno 111] Connection refused

macsnoeren commented 2 years ago

Implemented a solution (commit: a65ab8dc2ff0e4d2f6424e84a011ab42bcbe8fb8), which is now active).