[ERROR] [org.influxdb.impl.BatchProcessor ] - Batch could not be sent. Data will be lost java.lang.NullPointerException: null

Im getting these errors quite alot since upgrading to OH3.
it seems to stay away for a while when restarting the influxdb persistence in console.
Before null it gives these errors:

[internal.handler.ScriptActionHandler] - Script execution of rule with UID 'energie-8' failed: java.net.ProtocolException: Unexpected status line: 4.4 in energie
Batch could not be sent. Data will be lost
org.influxdb.InfluxDBIOException: java.net.ProtocolException: Unexpected status line: Type: text/plain; charset=utf-8
Batch could not be sent. Data will be lost
org.influxdb.InfluxDBIOException: java.net.ProtocolException: Unexpected status line: TP/1.1
Batch could not be sent. Data will be lost
org.influxdb.InfluxDBIOException: java.net.ProtocolException: Unexpected status line: 21HTTP/1.1 400 Bad Request
Batch could not be sent. Data will be lost
org.influxdb.InfluxDBIOException: java.net.ProtocolException: Unexpected status line: :8086
Batch could not be sent. Data will be lost
org.influxdb.InfluxDBIOException: java.net.ProtocolException: Unexpected status line: 21HTTP/1.1 400 Bad Request
Batch could not be sent. Data will be lost
org.influxdb.InfluxDBIOException: java.net.ProtocolException: Unexpected status line: **********
Batch could not be sent. Data will be lost
org.influxdb.InfluxDBIOException: java.net.ProtocolException: Unexpected status line: hab_db&rp=autogen&precision=n&consistency=one HTTP/1.1

it is hard to track this, debug isn’t very helpful, and it spams the logs in such short time, that all my log files are filled with the same error.
it looks to my as it cannot login in my influxdb or something?

Similar problem since upgrading to 2.5.11-1
My error is :-
retrofit.RetrofitError: 4096

Today was checking a completely different thing and found out that my OH 2.5.10 also keeps crying:
22:12:42.301 [ERROR] [org.influxdb.impl.BatchProcessor ] - Batch could not be sent. Data will be lost
retrofit.RetrofitError: Connection refused (Connection refused)
at retrofit.RetrofitError.networkError(RetrofitError.java:27) ~[retrofit-1.9.0.jar:?]
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395) ~[retrofit-1.9.0.jar:?]
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240) ~[retrofit-1.9.0.jar:?]
at org.influxdb.impl.$Proxy182.writePoints(Unknown Source) ~[?:?]
at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:151) ~[influxdb-java-2.2.jar:?]
at org.influxdb.impl.BatchProcessor.write(BatchProcessor.java:171) [influxdb-java-2.2.jar:?]
at org.influxdb.impl.BatchProcessor.put(BatchProcessor.java:188) [influxdb-java-2.2.jar:?]
at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:137) [influxdb-java-2.2.jar:?]
at org.openhab.persistence.influxdb.internal.InfluxDBPersistenceService.store(InfluxDBPersistenceService.java:254) [bundleFile:?]
at org.openhab.core.persistence.internal.PersistenceServiceDelegate.store(PersistenceServiceDelegate.java:59) [bundleFile:?]
at org.eclipse.smarthome.core.persistence.internal.PersistenceManagerImpl.handleStateEvent(PersistenceManagerImpl.java:137) [bundleFile:?]
at org.eclipse.smarthome.core.persistence.internal.PersistenceManagerImpl.stateChanged(PersistenceManagerImpl.java:437) [bundleFile:?]
at org.eclipse.smarthome.core.items.GenericItem$1.run(GenericItem.java:261) [bundleFile:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:1.8.0_222]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:1.8.0_222]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:1.8.0_222]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:1.8.0_222]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:1.8.0_222]
at java.net.Socket.connect(Socket.java:589) ~[?:1.8.0_222]
at com.squareup.okhttp.internal.Platform.connectSocket(Platform.java:100) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.internal.http.SocketConnector.connectRawSocket(SocketConnector.java:160) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.internal.http.SocketConnector.connectCleartext(SocketConnector.java:67) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.Connection.connect(Connection.java:152) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:185) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:341) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.Call.getResponse(Call.java:273) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201) ~[okhttp-2.4.0.jar:?]
at com.squareup.okhttp.Call.execute(Call.java:81) ~[okhttp-2.4.0.jar:?]
at retrofit.client.OkClient.execute(OkClient.java:53) ~[retrofit-1.9.0.jar:?]
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326) ~[retrofit-1.9.0.jar:?]
… 14 more
Why http? What is it trying to send and where ? I did not set up any cloud connectivity.

Ops, and just found out that my Grafana dashboards are empty with no data

Where is influx running and is the port listening? Can you login to the db using influx command line?

Influx uses http as it transport method

/etc/openhab/services$ cat influxdb.cfg
url=http://whateverIP:8086

$ ps -ef|grep influx
influxdb 88 1 1 Jan06 ? 00:26:30 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
admin 1273 1248 0 09:32 pts/2 00:00:00 grep --color=auto influx
[admin@database ~]$ netstat -na|grep 8086
tcp 0 0 127.0.0.1:57022 127.0.1.1:8086 ESTABLISHED
tcp 0 0 127.0.0.1:48716 127.0.1.1:8086 ESTABLISHED
tcp6 0 0 :::8086 :::* LISTEN

Hi! Indeed, i was able to figure out myself that the influx server was not running. Attempt to start it caused some unexplained errors with some dump in /var/log/faillog.
I know that yesterday i shut down my system for some HW maintenance and did not do it the proper way, just killed the power. The EXT4 hard drive with the database got corrupted. I fixed the problem using fsck.
By the way, any advice how to prevent such breakage in future ?

Not sure on the corruption side (I have the odd power trip but not seen that)

I use my grafana to alert me when values are missing in my graphs, which usually is due to me taking something off line (or my wife unplugging the zwave sensor in our bedroom)

I just restart the binding on midnight in a rule, my server is not running locally, and didn’t have any problems before.

Hi @Mickroz ,

can you post that rule? would be great!

br

Dominik

Sure, you need to have sshpass and exec binding installed, and run it once for openhab user for it to work.
Exec.things

Thing exec:command:influxdb "Restart InfluxDB Binding" @ "InfluxDB" [command="/usr/bin/sshpass -p habopen ssh -p 8101 openhab@localhost 'bundle:restart org.openhab.persistence.influxdb'", interval=0, timeout=15, autorun=true, transform="REGEX((.*))"]

Influx.items

Switch InfluxDB_restart_binding	"InfluxDB - Reset Binding" { channel="exec:command:influxdb:run" }
DateTime InfluxDB_last_restart		"InfluxDB - Last Restart binding [%1$ta %1$tr]" { channel="exec:command:influxdb:lastexecution" }

Influx.rules

rule "restart influxdb"
when
  Time is midnight or
  Time is noon
then
  InfluxDB_restart_binding.sendCommand(ON)
end
1 Like

Similar issue for me this morning (OH 3.0.1). For every item change which leads to an influx entry I got the following exception in the log:

2021-04-14 08:02:00.451 [ERROR] [org.influxdb.impl.BatchProcessor    ] - Batch could not be sent. 
     Data will be lost

    java.lang.NullPointerException: null

	at okio.Segment.push(Segment.java:111) ~[bundleFile:?]

	at okio.Buffer.writableSegment(Buffer.java:1307) ~[bundleFile:?]

	at okio.Buffer.writeUtf8(Buffer.java:980) ~[bundleFile:?]

	at okio.Buffer.writeUtf8(Buffer.java:961) ~[bundleFile:?]

	at okio.RealBufferedSink.writeUtf8(RealBufferedSink.java:53) ~[bundleFile:?]

	at okhttp3.internal.http1.Http1ExchangeCodec.writeRequest(Http1ExchangeCodec.java:196) ~[bundleFile:?]

	at okhttp3.internal.http1.Http1ExchangeCodec.writeRequestHeaders(Http1ExchangeCodec.java:141) ~[bundleFile:?]

	at okhttp3.internal.connection.Exchange.writeRequestHeaders(Exchange.java:72) ~[bundleFile:?]

Restarting the influx bundle helped but rather than putting that in a rule I would like to know the root cause. Any idea?

I don’t have this user. Do I have to install sshpass to execute this? (not an linux expert… )

Yes, you have to install sshpass on your system first.

Any news on that? I have the same issue and would like to find out the cause of the error.

Still facing this issue on 3.1.0, and im restarting the binding every 6 hours now.

1 Like

i am having the same problem with 3.1.0: only restarting the influxdb-binding every few hours gets my influxdb logging back. any news on this?

No change here, still restarting the binding every few hours, im too on 3.1.0

1 Like

how do you restart the binding? i tried using your items/things/rules but it does not work. Seems like when this error happens the trigger chokes up as well.
I also tried adding the command as a syste cron (using crontab) and restart the bundle every 2 hours, does not have an effect.
Only if apply it manually on CLI it takes effect (/usr/bin/sshpass -p habopen ssh -p 8101 openhab@localhost 'bundle:restart org.openhab.persistence.influxdb')

Im restarting it every 2 hours now.
I use this rule:

rule "restart influxdb"
when
  Time cron "0 0 0/2 1/1 * ? *"
then
  InfluxDB_restart_binding.sendCommand(ON)
end

And this is my item:

Switch InfluxDB_restart_binding	"InfluxDB - Reset Binding" (gTests) { channel="exec:command:influxdb:run" }
DateTime InfluxDB_last_restart		"InfluxDB - Last Restart binding [%1$ta %1$tr]" (gTests) { channel="exec:command:influxdb:lastexecution" }

Running that in cron I would add the related path to the ssh command.
stdout and stderr output is normally sent via mail resp. stored in /var/mail of the user’s account that runs the related cronjob. Is there any error message ? You also may check system log messages.

Try to run:

echo bundle:restart org.openhab.persistence.influxdb | /usr/bin/openhab-cli console -p habopen
1 Like