02_07_03: iotawatt stops uploading data in influxdbv2 after power reset ( Last sent query failed. HTTPcode 400 )

I restarted power in my house today and Iotawatt stopped uploading data to by influxdbv2 database with an error “Last sent query failed. HTTPcode 400”.

Restarting the uploader did not help.

Message log:
** Restart **

SD initialized.
11/17/21 07:35:17z Real Time Clock is running. Unix time 1637134517
11/17/21 07:35:17z Reset Reason: Power-fail restart.
11/17/21 07:35:17z ESP8266 ID: 12704151, RTC PCF8523
11/17/21 07:35:17z IoTaWatt 5.0, Firmware version 02_07_03
11/17/21 07:35:17z SPIFFS mounted.
11/17/21 14:35:17 Local time zone: +7:00
11/17/21 14:35:17 device name: IotaWatt
11/17/21 14:35:20 Connecting with WiFiManager.
11/17/21 14:35:25 HTTP server started
11/17/21 14:35:25 influxDB_v2: Starting, interval:10, url:http://domain.com:18086
11/17/21 14:35:25 WiFi connected. SSID=BDSM Villa, IP=192.168.86.147, channel=11, RSSI -85db
11/17/21 14:35:25 MDNS responder started for hostname IotaWatt
11/17/21 14:35:25 LLMNR responder started for hostname IotaWatt
11/17/21 14:35:25 timeSync: service started.
11/17/21 14:35:26 statService: started.
11/17/21 14:35:26 Updater: service started. Auto-update class is NONE
11/17/21 14:35:26 dataLog: service started.
11/17/21 14:35:26 dataLog: Last log entry 11/17/21 14:26:45
11/17/21 14:35:31 historyLog: service started.
11/17/21 14:35:31 historyLog: Last log entry 11/17/21 14:26:00
11/17/21 16:02:30 influxDB_v2: stopped, Last post 01/01/70 07:00:00

Uploader config:
post interval(sec):
10
bulk send:
6
server URL:
http://ip.ip.102.66:18086/api/v2/
Bucket:
iotawatt
Organization ID:
4b9d461751e3aff8
Authorization token:
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
upload history from:
11/01/2021
measurement
default is $name
field-key
default is ‘value’

Switching server name from domain to IP did not help. tcpdump on the server side shows 0 packets coming from the iotawatt device. Oh, and I am using an unusual port (18086 instead of 8086).

There have been issues with the influxDB2 flux query. 02_07_04 is pretty much dedicated to resolving those issues. I see that your auto-update is NONE. That’s fine, but at some point I think you will need to upgrade to 02_07_04 to resolve this issue.

There are some workarounds for some of the problems fixed in 02_07_04, but without seeing your actual influx config display, I can’t say if any are applicable.

Today I posted instructions for manual version update should you decide to try that.

2 Likes

Thank you. Updating to 02_07_04 fixed the problem.

Thank you. It works for my InfluxDB 2.0.7. But with InfluxDB 2.1.1 I am getting an 404. Any ideas?

–EDIT:
Nevermind: I saw that i need to add ‘/api/v2’ to the server URL

I’ve noticed a lot of people miss the “/api/v2” (me included). Perhaps it might be a good idea to add an example under the form? Will save everyone at least a few minutes.

That should be a non-issue with the latest release. It should work either way.

1 Like

I just ran into this issue for the second time. Are there still known influxDB2 flux query issues? Or a simple fix to get it uploading again?

** Restart **

SD initialized.
7/16/22 17:24:24z Real Time Clock is running. Unix time 1657992264 
7/16/22 17:24:24z Reset reason: Software/System restart
7/16/22 17:24:24z Trace:  1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:1[6], 1:2[7], 9:0[7], 9:0, 9:1, 8:4, 8:6, 8:8, 8:9, 9:3, 9:5, 9:9, 1:2, 1:3, 10:2, 10:3
7/16/22 17:24:24z ESP8266 ID: 15918360, RTC PCF8523 (68)
7/16/22 17:24:24z IoTaWatt 5.0, Firmware version 02_07_05
7/16/22 17:24:24z SPIFFS mounted.
7/16/22 14:24:24 Local time zone: -4:00, using DST/BST when in effect.
7/16/22 14:24:24 device name: IotaWatt
7/16/22 14:24:24 HTTP server started
7/16/22 14:24:24 influxDB_v2: Starting, interval:10, url:http://192.168.50.2:8086
7/16/22 14:24:24 timeSync: service started.
7/16/22 14:24:24 statService: started.
7/16/22 14:24:24 dataLog: service started.
7/16/22 14:24:24 dataLog: Last log entry 07/16/22 14:24:20
7/16/22 14:24:28 WiFi connected. SSID=dachnet, IP=192.168.50.137, channel=3, RSSI -52db
7/16/22 14:24:28 MDNS responder started for hostname IotaWatt
7/16/22 14:24:28 LLMNR responder started for hostname IotaWatt
7/16/22 14:24:28 Updater: service started. Auto-update class is MINOR
7/16/22 14:24:29 historyLog: service started.
7/16/22 14:24:29 historyLog: Last log entry 07/16/22 14:24:00
7/16/22 14:24:31 Updater: Auto-update is current for class MINOR.
7/16/22 16:07:29 influxDB_v2: Start posting 07/10/22 11:58:10
7/16/22 23:32:36 WiFi disconnected.
7/16/22 23:32:41 WiFi connected. SSID=dachnet, IP=192.168.50.137, channel=3, RSSI -73db
7/17/22 05:00:24 WiFi disconnected.
7/17/22 05:01:28 WiFi connected. SSID=dachnet, IP=192.168.50.137, channel=6, RSSI -50db
7/17/22 14:54:49 WiFi disconnected.
7/17/22 14:54:54 WiFi connected. SSID=dachnet, IP=192.168.50.137, channel=4, RSSI -72db
7/19/22 15:41:33 Heap memory has degraded below safe minimum, restarting.

** Restart **

SD initialized.
7/19/22 18:41:35z Real Time Clock is running. Unix time 1658256095 
7/19/22 18:41:35z Reset reason: Software/System restart
7/19/22 18:41:35z Trace:  8:8, 8:9, 9:3, 9:5, 9:9, 1:2, 1:3, 1:3, 1:6[1], 1:6[2], 1:6[2], 1:6[3], 1:5[31], 1:6[4], 31:0, 31:1, 31:2[6], 31:90, 31:93, 31:1, 1:6[6], 1:3, 1:3, 1:6[1], 1:6[2], 1:6[3], 1:5[21], 1:6[4], 21:0, 21:1, 21:10, 21:10
7/19/22 18:41:35z ESP8266 ID: 15918360, RTC PCF8523 (68)
7/19/22 18:41:35z IoTaWatt 5.0, Firmware version 02_07_05
7/19/22 18:41:35z SPIFFS mounted.
7/19/22 15:41:35 Local time zone: -4:00, using DST/BST when in effect.
7/19/22 15:41:35 device name: IotaWatt
7/19/22 15:41:35 HTTP server started
7/19/22 15:41:35 influxDB_v2: Starting, interval:10, url:http://192.168.50.2:8086
7/19/22 15:41:35 timeSync: service started.
7/19/22 15:41:35 statService: started.
7/19/22 15:41:35 dataLog: service started.
7/19/22 15:41:35 dataLog: Last log entry 07/19/22 15:41:30
7/19/22 15:41:40 historyLog: service started.
7/19/22 15:41:40 historyLog: Last log entry 07/19/22 15:41:00
7/19/22 15:41:41 WiFi connected. SSID=dachnet, IP=192.168.50.137, channel=4, RSSI -56db
7/19/22 15:41:41 MDNS responder started for hostname IotaWatt
7/19/22 15:41:41 LLMNR responder started for hostname IotaWatt
7/19/22 15:41:41 Updater: service started. Auto-update class is MINOR
7/19/22 15:41:43 Updater: Auto-update is current for class MINOR.

Please post your influx setup.

should have foresaw that one :slight_smile:

Anything wrong with the setup?
It was working for a while before it stopped after power reset.

I just tried stopping the uploader, giving it a new token and a recent “upload history from” date and saved it. Then restarted my influxdb container, then started the uploader and it immediately gave the same HTTPcode 400 error. Last time I “resolved” this by scrapping the influxdb and starting from scratch. I can’t do that everytime…

Is there an influxDB version you can recommend/know is stable?
Or have anyway to inspect the http request to identify why its a “bad request” ?

Thanks,

Edit:
I got it running again by: creating a new bucket and token, and updating the uploader to use the new bucket and token.

The problem appears to be with the tag-key iotawatt.id. As currently coded, the uploader does not quote the tag-key in the startup flux query, and the flux parser doesn’t recognize it as a string without quotes. The workaround is to change the tag-key to something that will be recognized as a string. You can remove the period or replace it with an underscore. That should solve the startup query problem.

I see that you are using periods in many of the measurement names. I’ve tested that and it seems to work in the query and the data writes, but I would caution you that it may cause other problems if you do not single quote them every time you use them in a query.

1 Like