Closed plaksnor closed 5 years ago
Seems like a wrong config.json was loaded (the one in the docker container, not the one which was mapped to my customized config.json outside the docker container). The one in the docker container has the line:
"GRAFANA_URL": "http://localhost:3000",
which I now changed for testing purposes to
"GRAFANA_URL": "https://external_wan_ip_address:3000",
And this seems to work, but leads me into some other issue.
Restarted hastic-server with npm start
gives me the following error:
LEARNING started for wM9Yoluht3luTIPY
query time range: from Fri Aug 16 2019 10:12:48 GMT+0000 (Coordinated Universal Time) to Fri Aug 23 2019 10:12:48 GMT+0000 (Coordinated Universal Time)
Error: Cannot read property 'length' of undefined
at /hastic-server/server/dist/server.js:9:92782
at Generator.next (<anonymous>)
at a (/hastic-server/server/dist/server.js:9:87908)
In order to make any sense of it, I used the server-dev.js file instead of server.js, which gives me exact line and pos specifications of the location of the code which is causing the error:
LEARNING started for wM9Yoluht3luTIPY
query time range: from Fri Aug 16 2019 10:18:59 GMT+0000 (Coordinated Universal Time) to Fri Aug 23 2019 10:18:59 GMT+0000 (Coordinated Universal Time)
Error: Cannot read property 'length' of undefined
at /hastic-server/server/dist/server.js:19337:19
at Generator.next (<anonymous>)
at fulfilled (/hastic-server/server/dist/server.js:19041:32)
I think there's an issue with the runLearning function, which is not able to define a 'segments' var:
let segments = yield Segment.findMany(id, { labeled: true });
if (segments.length === 0) {
throw new Error('Need at least 1 labeled segment');
}
segments is probably not defined. Any thoughts?
I think
if (res.data === undefined || res.data.results.length < 1) {
console.log('datasource return empty response, no data');
return emptyResult;
}
should be changed to:
if (res.data === undefined || res.data.results === undefined || res.data.results.length < 1) {
console.log('datasource return empty response, no data');
return emptyResult;
}
which at least causes the code to give back a decent message:
Error: Empty data to detect on
at /hastic-server/server/dist/server.js:19341:19
at Generator.next (<anonymous>)
at fulfilled (/hastic-server/server/dist/server.js:19041:32)
API could not been accessed, but finally got the right grafana_url (it's complicated when using Hass.io) and got another error.
LEARNING started for BRl1jNQ8K104WG51
query time range: from Sun Aug 18 2019 15:20:09 GMT+0000 (Coordinated Universal Time) to Sun Aug 18 2019 17:52:48 GMT+0000 (Coordinated Universal Time)
Error: e is not defined
at /hastic-server/server/dist/server.js:19339:19
at Generator.next (<anonymous>)
at fulfilled (/hastic-server/server/dist/server.js:19041:32)
Problem solved when going back from server-dev.js to server.js.
So in short: It works in SSL, just use the right address in order to communicate with the API.
@plaksnor thank you a lot! Sorry for being slow.
TL;DR: After labelling a selected period in Grafana, hastic-server shows an http 400 error: Client sent an HTTP request to an HTTPS server.
Context: Running RPi4 (arm7l architecture) with Hass.io (Home Assistant in docker) with addons Influxdb and Grafana, all in separate docker containers. All secured with SSL by LetsEncrypt. Succesfully managed to build hastic-server. No errors during the tests in the development section on this page. Also succesfully managed to install the hastic-grafana-app in the grafana docker add-on of Hass.io.
I created and tested my Hastic datasource in Grafana, which refers to a HTTP (instead of HTTPS) url, with port 8000. When I add an AnalyticUnit and start labelling data according to this page, the hastic-server (started with
npm start
) shows an error:This is my config.json:
I'm aware the webhook part should probably not work, but I'm not even close to get it working at all. Question: does anyone know if hastic-server support SSL, or is there something configured wrong in my setup?
Whole log of hastic-server: