Are there any plans to support hooks such as connected, disconnected, authenticate?
Is your enhancement request related to a problem? Please describe. Are there any plans to support hooks such as connected, disconnected, authenticate? Describe the solution you'd like In IoT application scenarios, we often pay attention to when the device is connected or disconnected, as well as the time and result of device authentication. Can the corresponding hook be enabled in a configurable way to convert the message to the pulsar protocol? The back-end program can monitor when the device is connected or disconnected by subscribing to the configured topic
@liweiv
Do you want MOP to push events to a specific topic, and then you can use pulsar or mqtt client to monitor it?
@mattisonchao Yes, I want to use pulsar protocol to monitor it. This is very useful for backend server program to handle some business logical.
@liweiv
I think it's a good suggestion. what do you think about it ? @Technoboy-
Hi @liweiv, this is really a good suggestion, but I'm not sure if some other MQTT implementations that support this feature?
We can check this feature first and then make a MIP to discuss. @mattisonchao
@Technoboy-
Ok, i will work on it.
@Technoboy- This feature can be found in emqx.
@liweiv
Do you mean this feature in emqx ?
the link is : https://docs.emqx.io/en/enterprise/v4.4/advanced/hooks.html#callback-function
@Technoboy- @liweiv
I think we current do not need to support hook, because MOP just is a protocol plugin for pulsar. add hook will be too complicated
But we can support system event topic to push event by json format.
What do you guys think about this.
If agree, i will submit a MIP.
@Technoboy- Ok, I think the way of event topic can solve problems。
But we can support system event topic to push event by json format.
make sense.
@liweiv @liangyuanpeng @Technoboy-
Ok, I will submit a MIP.
@liweiv You can track connected status through LWT which is part of the MQTT standard for basically this exact reason. Typical implementation would be that an MQTT client sets up an LWT message which is fired by the broker when the keep alive mechanism fails signaling that the connection is likely dead. Expected behavior here is that you'd fire a message on client disconnect, similarly on graceful disconnect you'd just send a message before you disconnect. To handle connect events just publish connect events when you connect, or a more robust approach would be to have your connection status message be retained, so that you can have the client itself subscribe on it's connection topic and always send a conneced status in response to any disconnected status messages. This way if LWT fires from another broker, and you reconnected to a different broker and publish a connected message before the LWT fires, you can correct the potential race condition that occurs. So this mechanism is baked into the MQTT standard, and is a very common means to do the exact type of connection tracking you're talking about.
Unfortunately LWT in MoP does not behave correctly, as it only publishes LWT events to MQTT subscribers, and LWTs currently do not reach Pulsar topics at all. I have proposed a fix for this, however it's gotten no response in several months: https://github.com/streamnative/mop/pull/943