Skip to main content



      Home
Home » Eclipse Projects » Kura » Decode kura MQTT message using third party client libraries in C#(Unable to decode an MQTT payload message on .NET using m2mqtt.codeplex.com)
Decode kura MQTT message using third party client libraries in C# [message #1586150] Mon, 26 January 2015 12:49 Go to next message
Eclipse UserFriend
Hi All

I am running kura on a raspberry pi and installed the demo sample package org.eclipse.kura.demo.heater. I use Apache Apollo message broker installed on my machine.

Kura succesfully connects to Apollo and publishes the messages periodically.

I built a small MQTT client in C# .NET using m2mqtt.codeplex.com.
The client connects to Apollo and receives the MQTT messages but I could not find any way to decode the payload which seems to be in a binary format.

I tried to use google protobuf-net libray to decode the payload assumng this is compressed using the google standard but I get all sorts of errors, looks like the format is different than what protobuf can handle.

Is there any way I can decode the kura payload in .NET using some third party library, do I need to write a custom decoder?

Thanks in advance
Dan

[Updated on: Tue, 27 January 2015 16:31] by Moderator

Re: Decode kura MQTT message using third party client libraries [message #1586555 is a reply to message #1586150] Mon, 26 January 2015 18:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dan,

So you are aware, the heater demo uses the CloudService to send data which is where the payload is being serialized using Google Protocol Buffers. This is not a requirement of Kura as you could modify the heater demo to simply use regular MQTT publishes. That being said, using protocol buffers certainly offers a performance enhancement and the CloudService offers many nice features in managing the broker connection [1]. Let me know if you need more explanation on any of this.

I am not sure what you mean by "google protobuf-net library". In order to encode/decode a Google protobuf message, you must first compile the .proto file [2]. This has already been done in Kura, but you would need to compile the .proto file for any other languages you needed to support. I have never tried C#, but here are tutorials for languages documented by Google [3]

[1] http://download.eclipse.org/kura/releases/1.1.0/docs/apidocs/org/eclipse/kura/cloud/CloudService.html
[2] https://github.com/eclipse/kura/blob/develop/kura/org.eclipse.kura.core.cloud/src/main/protobuf/kurapayload.proto
[3] https://developers.google.com/protocol-buffers/docs/tutorials

Thanks,
--Dave



Re: Decode kura MQTT message using third party client libraries [message #1587355 is a reply to message #1586555] Tue, 27 January 2015 04:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dave,

Many thanks for your guidance, this helps me to progress towards finding a solution.

By "google protobuf-net library" I meant a C# library that I thought could help me so I don't write the decoding bit from scratch: https://code.google.com/p/protobuf-net/.

Will post my progress in this thread.

Best
Dan
Re: Decode kura MQTT message using third party client libraries [message #1588293 is a reply to message #1587355] Tue, 27 January 2015 16:31 Go to previous messageGo to next message
Eclipse UserFriend
Some updates:

1. I have managed to use the "standard" MQTT messages from kura using apache paho library, see this example https://eclipse.org/paho/clients/java/

2. I have tried 3 different C# proto libraries and I have converted the kurapayload.proto to corresponding C# classes, but all 3 libraries are throwing exceptions on deserialisation around invalid wire type (e.g. Protocol message tag had invalid wire type, or this error https://github.com/hultqvist/ProtoBuf/issues/24).
I suspect that the CloudService implementation for some reason is not compatible with the default Google protocol.

The libraries I have tried are these:
https://silentorbit.com/protobuf/
https://code.google.com/p/protobuf-net/
https://code.google.com/p/protobuf-csharp-port/

So unfortunately I see no way currently to use the built-in CloudService MQTT messages and integrate with clients built in C# which is a pitty as limits the kura interoperability with .NET world.

Happy to hear if anyone has a solution for this.

[Updated on: Tue, 27 January 2015 16:32] by Moderator

Re: Decode kura MQTT message using third party client libraries [message #1589802 is a reply to message #1588293] Wed, 28 January 2015 12:14 Go to previous messageGo to next message
Eclipse UserFriend
I'll take a look on this one.
Kura .proto works perfectly in Python, so I'm curious about what happens in .NET
Re: Decode kura MQTT message using third party client libraries [message #1595140 is a reply to message #1589802] Sat, 31 January 2015 15:16 Go to previous messageGo to next message
Eclipse UserFriend
Problem solved, was just a kura configuration issue.
The problem is kura payload by default is gzipped so can't be recognised on decode properly.

Went to CloudService settings on kura webadmin interface and set encode.gzip to false.
Re: Decode kura MQTT message using third party client libraries [message #1768255 is a reply to message #1595140] Sun, 16 July 2017 00:29 Go to previous message
Eclipse UserFriend
Dear Dan :

Could you show me how to use kura and Apollo? I have failed in connecting to Apollo . Thank you very much . My Apollo is running on Windows 7, and the
cloud service configuration in kura is : tcp://192.168.1.101:61613.

Thank you very much !

Best regards
LiYi
Previous Topic:Why can not publishi topic to HiveMQ?
Next Topic:About Cloud and MQTT
Goto Forum:
  


Current Time: Sun Jul 27 09:00:28 EDT 2025

Powered by FUDForum. Page generated in 0.04520 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top