I send this valid JSON to TB CE edition, and it fails reading it.
mosquitto_pub -d -q 1 -h “192.168.0.108” -t “device/sck/ybuers/readings” -i xxxxx -m
{"ts":"2021-11-08T16:17Z","value1":"99","value2":"24"}
If I send: (just changing the ts format to UNIX style)
mosquitto_pub -d -q 1 -h “192.168.0.108” -t “device/sck/ybuers/readings” -i xxxxx -m
{"ts":"12345678910","value1":"99","value2":"24"}
it works.
Is this a BIG limitation of the platform? or am I missing something basic? I'm working with TB CE v3.3.1, on Windows.
I paste the error from /var/log/thingsboard below.
Thank you!
2021-11-09 15:25:23,583 [nioEventLoopGroup-4-2] INFO o.t.s.t.mqtt.MqttTransportHandler - [d13716f2-1a55-4056-93c8-11b81bc7794b] Processing connect msg for client: ybuers!
2021-11-09 15:25:23,583 [nioEventLoopGroup-4-2] INFO o.t.s.t.mqtt.MqttTransportHandler - [d13716f2-1a55-4056-93c8-11b81bc7794b] Processing connect msg for client with user name: null!
2021-11-09 15:25:23,639 [DefaultTransportService-28-60] INFO o.t.s.t.mqtt.MqttTransportHandler - [d13716f2-1a55-4056-93c8-11b81bc7794b] Client connected!
2021-11-09 15:25:23,644 [nioEventLoopGroup-4-2] WARN o.t.s.t.mqtt.MqttTransportHandler - [d13716f2-1a55-4056-93c8-11b81bc7794b] **Failed to process publish msg [device/sck/ybuers/readings][1]**
org.thingsboard.server.common.transport.adaptor.AdaptorException: com.google.gson.JsonSyntaxException: **com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 18 path $.t**
at org.thingsboard.server.transport.mqtt.adaptors.JsonMqttAdaptor.convertToPostTelemetry(JsonMqttAdaptor.java:67)
at org.thingsboard.server.transport.mqtt.MqttTransportHandler.processDevicePublish(MqttTransportHandler.java:343)
at org.thingsboard.server.transport.mqtt.MqttTransportHandler.processPublish(MqttTransportHandler.java:298)
at org.thingsboard.server.transport.mqtt.MqttTransportHandler.processRegularSessionMsg(MqttTransportHandler.java:255)
at org.thingsboard.server.transport.mqtt.MqttTransportHandler.lambda$processMsgQueue$0(MqttTransportHandler.java:249)
at org.thingsboard.server.transport.mqtt.session.DeviceSessionCtx.tryProcessQueuedMsgs(DeviceSessionCtx.java:181)
at org.thingsboard.server.transport.mqtt.MqttTransportHandler.processMsgQueue(MqttTransportHandler.java:249)
at org.thingsboard.server.transport.mqtt.MqttTransportHandler.enqueueRegularSessionMsg(MqttTransportHandler.java:241)
at org.thingsboard.server.transport.mqtt.MqttTransportHandler.processMqttMsg(MqttTransportHandler.java:183)
at org.thingsboard.server.transport.mqtt.MqttTransportHandler.channelRead(MqttTransportHandler.java:156)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 18 path $.t
at com.google.gson.internal.Streams.parse(Streams.java:60)
at com.google.gson.JsonParser.parse(JsonParser.java:84)
at com.google.gson.JsonParser.parse(JsonParser.java:59)
at com.google.gson.JsonParser.parse(JsonParser.java:45)
at org.thingsboard.server.transport.mqtt.adaptors.JsonMqttAdaptor.convertToPostTelemetry(JsonMqttAdaptor.java:65)
... 30 common frames omitted
Caused by: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 18 path $.t
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1567)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:495)
at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:418)
at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:742)
at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:718)
at com.google.gson.internal.Streams.parse(Streams.java:48)
... 34 common frames omitted
2021-11-09 15:25:23,645 [nioEventLoopGroup-4-2] INFO o.t.s.t.mqtt.MqttTransportHandler - [d13716f2-1a55-4056-93c8-11b81bc7794b] Closing current session due to invalid publish msg [device/sck/ybuers/readings][1]
2021-11-09 15:25:23,646 [nioEventLoopGroup-4-2] INFO o.t.s.t.mqtt.MqttTransportHandler - [d13716f2-1a55-4056-93c8-11b81bc7794b] Client disconnected!
2021-11-09 15:25:23,664 [nioEventLoopGroup-4-1] INFO o.t.s.t.mqtt.MqttTransportHandler - [f03fba50-a2be-4c2f-a301-a48c79d6baaf] Client disconnected!
CodePudding user response:
If you're using windows to execute that cmd, try using windows format quotes.
"{\"ts\":\"12345678910\",\"value1\":\"99\",\"value2\":\"24\"}"