mochi-mqtt / server

The fully compliant, embeddable high-performance Go MQTT v5 server for IoT, smarthome, and pubsub

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MQTT transport for IoT platform/framework

oherych opened this issue · comments

Hello. First of all, I want to say that project looks pretty good. But I have questions and comments.

I'm working on my own hybrid solution of the open-source IoT platform/framework. In my world gateway is a central component. It will be responsible for communication with devices and based on provided configuration it running different scenarios.

So, I selected this package because I can embed it into my application. And this is awesome.

Actually, I don't use most parts of functionality like retaining messages. In my case I just receive msg from a device, validate and push it to Nats queue. For the commutation server to the device, I use WritePacket() method.

Right now I have the next issues:

  • How I can validate and inform MQTT client about a problem? I found that we have a variable with the name ErrPayloadFormatInvalid but I don't see, how I can use it. If I will return this error in the method OnPublish it will be ignored.
  • Does exist a way to prevent retaining messages? In my case, this is just an additional load.

I'm ready to contribute to this project but I don't know deep MQTT protocol and general plans

commented

I'll try to get to this today with some clear answers for you 👍🏻

@mochi-co, one additional thing. Great idea, great implementation but in my opinion that are small chaos. For looks like new features was added without a general plan.

Perhaps the are sense to create version 3 and have separate layers? One for transport and one for rotation and rest functionality?

commented

@oherych Which features are you referring to?

commented

How I can validate and inform MQTT client about a problem? I found that we have a variable with the name ErrPayloadFormatInvalid but I don't see, how I can use it. If I will return this error in the method OnPublish it will be ignored.

I think this is mostly answered in #249, and #256

Does exist a way to prevent retaining messages? In my case, this is just an additional load.

You can leverage MQTT v5 capabilities flags:

server := mqtt.New(nil)
server.Options.Capabilities.RetainAvailable = 0

However, while it will indicate to the client that retain is unavailable, there's no code in place to prevent it actually retaining incoming publish packets. I've opened a PR for it which will correct this behaviour - #261.

I'm ready to contribute to this project but I don't know deep MQTT protocol and general plans

All contributions are welcome, even if they are just small. PR reviews too!

thanks. Let me check

commented

These changes have been released in v2.2.16 - thanks for raising it @oherych!