Null ('\x00') character at the end of mqtt message - telegraf can't parse it into metrics

Hi everyone,

I’m working on some project, where I need to collect data to influxdb using mqtt input plugin in telegraf. But I’m facing strange behaviour of mqtt input. I’m sending data on specific topic using JSON string (i.e. “{value”:15}", but MQTT producer, which I’m using adds null (’\x00’) char at the end of message. It looks like below:
MQTTBox2_small

First message was sent from MQTT producer and it has lenght of 41 bytes, while second I sent from regular MQTT client - MQTTBox - length of the second message is 40 bytes - null character at the end is missing. First message causes error in telegraf, while second is correctly wrote to database:

2020-05-16T14:03:14Z E! [inputs.mqtt_consumer] Error in plugin: invalid character '\x00' after top-level value
2020-05-16T14:03:15Z E! [inputs.mqtt_consumer] Error in plugin: invalid character '\x00' after top-level value

My current telegraf config file looks like this (I have to use multiple MQTT inputs to multiple Influx databases, but this not a problem):

[[outputs.influxdb]]
   urls = ["http://localhost:8086"]
   database = "telegraf_metrics_01"
   retention_policy = ""
   write_consistency = "any"
   timeout = "37s"
   tagexclude = ["destinationdb"]
   [outputs.influxdb.tagpass]
      destinationdb = ["db01"]

[[inputs.mqtt_consumer]]
   servers = ["tcp://localhost:1883"]
   qos = 0
   topics = [
      "test/maszyna1/#"
   ]
   data_format = "json"

   [inputs.mqtt_consumer.tags]
   destinationdb = "db01"

Do you have any idea, how to configure telegraf to (maybe) ignore those null characters, or cut this one byte using some processor plugin? I read some about proccessors.string.trim_right plugin, but It’s unclear for me how it works? Can it be used in my case, and how?
It’s also strange, because when I’m using “value” data_format of mqtt input instead of “json” - telegraf works fine with this mqtt producer, even at the end of simple value also null character appears.

I will appreciate any help, It starts to driving me crazy :smiley:
Have a good day!