Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT: Unable to process this rawMessage:RawMessage #245

Closed
ragflyer opened this issue Aug 18, 2016 · 7 comments
Closed

MQTT: Unable to process this rawMessage:RawMessage #245

ragflyer opened this issue Aug 18, 2016 · 7 comments

Comments

@ragflyer
Copy link

ragflyer commented Aug 18, 2016

I'm trying to receive data from an ESP8266 through the inbuilt MQTT Broker and get a lot of these:

2016-08-18 16:06:06,618 ERROR [Thread-3] [org.mycontroller.standalone.provider.mc.McProviderBridge:59] Unable to process this rawMessage:RawMessage(gatewayId=5, data=640.00, subData=mygateway-out/temperature, isTxMessage=false, networkType=MY_CONTROLLER)
org.mycontroller.standalone.message.RawMessageException: Unknown message format, Topic:mygateway-out/temperature, Payload:640.00
        at org.mycontroller.standalone.provider.mc.McpRawMessage.updateMQTTMessage(McpRawMessage.java:91) ~[mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at org.mycontroller.standalone.provider.mc.McpRawMessage.<init>(McpRawMessage.java:61) ~[mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at org.mycontroller.standalone.provider.mc.McProviderBridge.executeRawMessage(McProviderBridge.java:57) ~[mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at org.mycontroller.standalone.message.McMessageUtils.sendToProviderBridge(McMessageUtils.java:544) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at org.mycontroller.standalone.message.MessageMonitorThread.processRawMessage(MessageMonitorThread.java:64) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at org.mycontroller.standalone.message.MessageMonitorThread.run(MessageMonitorThread.java:85) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]

Hopefully it has nothing to do with the topic (I set humidity to -in and temperature to -out on the sensor as I had no idea which one mycontroller expects).

Relevant code from the .ino:

#define humidity_topic "mygateway-in/humidity"
#define temperature_topic "mygateway-out/temperature"
[...]
    float newTemp = dht.readTemperature();
    float newHum = dht.readHumidity();

    if (checkBound(newTemp, temp, diff)) {
      temp = newTemp;
      Serial.print("New temperature:");
      Serial.println(String(temp).c_str());
      client.publish(temperature_topic, String(temp).c_str(), true);
    }

    if (checkBound(newHum, hum, diff)) {
      hum = newHum;
      Serial.print("New humidity:");
      Serial.println(String(hum).c_str());
      client.publish(humidity_topic, String(hum).c_str(), true);
    }

Will mycontroller automatically create the sensors from received MQTT messages or do I have to set those up first?

@jkandasa
Copy link
Member

@ragflyer you can not send directly like you have mentioned. Currently MyController supports only for MySensors network type MQTT. You have to follow MySensors format.

Your topic should be like as follows,

Topic format: node-id/child-sensor-id/message-type/ack/sub-type
You have to post all the values on the topic mygateway-out.

#define humidity_topic "mygateway-out/12/1/1/0/1"
#define temperature_topic "mygateway-out/12/2/1/0/0"

You can see these values on MyController. Manually assign sensor type on MyController.

@ragflyer
Copy link
Author

Dear Jeeva,
that was very helpful for my understanding of things but unfortunately I still cannot get it right.
For testing I also tried variations in the message with the MQTT.fx client but none got parsed correctly. Just the error message changes to when I set the topic to just "mygateway-out" and move all ids and data to the message itself.
ERROR [nioEventLoopGroup-5-1] [io.moquette.server.netty.NettyMQTTHandler:84] Bad error in processing the message

Do you know of any working example to start with?
Thank you

@jkandasa
Copy link
Member

jkandasa commented Aug 19, 2016

@ragflyer By default Allow anonymous will be disabled, Enable it. Will be looking as follows,
image

And your gateway should look as follows,
image

Now try with this settings, it should work,

#define humidity_topic "mygateway-out/12/1/1/0/1"
#define temperature_topic "mygateway-out/12/2/1/0/0"

NOTE: On your ESP8266 device, you have point MyController MQTT broker with MyController IP.

@ragflyer
Copy link
Author

ragflyer commented Aug 19, 2016

Awesome, my mistake was in the 'network type' of the gateway, thanks a lot!

I can see the sensors now, the log still shows errors though:

2016-08-19 21:28:31,601 ERROR [nioEventLoopGroup-5-2] [io.moquette.server.netty.NettyMQTTHandler:84] Bad error in processing the message
java.lang.NullPointerException: null
        at io.moquette.spi.impl.ProtocolProcessor.route2Subscribers(ProtocolProcessor.java:460) ~[mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.moquette.spi.impl.ProtocolProcessor.processPublish(ProtocolProcessor.java:310) ~[mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.moquette.server.netty.NettyMQTTHandler.channelRead(NettyMQTTHandler.java:61) ~[mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.moquette.server.netty.metrics.MessageMetricsHandler.channelRead(MessageMetricsHandler.java:46) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:276) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:263) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.moquette.server.netty.metrics.BytesMetricsHandler.channelRead(BytesMetricsHandler.java:47) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [mycontroller-dist-standalone-0.0.3.Final-SNAPSHOT-single.jar:0.0.3.Final-SNAPSHOT]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]

@jkandasa
Copy link
Member

@ragflyer Yes, this is because no one subscribed mygateway-in topic. In your ESP8266 you are not subscribing any topic. But in MyController it is mandatory to update topic to publish(which is mygateway-in).

I hope you are using MyController v0.0.3.Aplha2 which is using moquette v0.8. This issue was fixed on moquette v0.8.1, I have updated on MyController v0.0.3.Final-SNAPSHOT.

For now you may hide this error by adding following line on your mycontroller/conf/logback.xml,

  <logger level="OFF" name="io.moquette.server.netty.NettyMQTTHandler" />

Please note, this line will hide all the errors on io.moquette.server.netty.NettyMQTTHandler

@MPParsley
Copy link

@jkandasa, I'm also seeing these errors in the log.

I couln't find "MyController v0.0.3.Final-SNAPSHOT" on the release page. Could you create a new release with this fix?

@jkandasa
Copy link
Member

@MPParsley SNAPSHOT version available here: http://forum.mycontroller.org/topic/58/download-snapshot-build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants