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

Are there any plans to support hooks such as connected, disconnected, authenticate? #355

Open
liweiv opened this issue Dec 24, 2021 · 12 comments
Assignees

Comments

@liweiv
Copy link

liweiv commented Dec 24, 2021

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

@mattisonchao
Copy link
Member

@liweiv

Do you want MOP to push events to a specific topic, and then you can use pulsar or mqtt client to monitor it?

@liweiv
Copy link
Author

liweiv commented Dec 25, 2021

@mattisonchao
Yes, I want to use pulsar protocol to monitor it. This is very useful for backend server program to handle some business logical.

@mattisonchao
Copy link
Member

@liweiv

I think it's a good suggestion. what do you think about it ? @Technoboy-

@Technoboy-
Copy link
Contributor

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

@mattisonchao
Copy link
Member

@Technoboy-

Ok, i will work on it.

@liweiv
Copy link
Author

liweiv commented Dec 27, 2021

@Technoboy- This feature can be found in emqx.

@mattisonchao
Copy link
Member

@liweiv

Do you mean this feature in emqx ?

the link is : https://docs.emqx.io/en/enterprise/v4.4/advanced/hooks.html#callback-function

@mattisonchao
Copy link
Member

@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.

@liweiv
Copy link
Author

liweiv commented Dec 28, 2021

@Technoboy-
Ok, I think the way of event topic can solve problems。

@liangyuanpeng
Copy link
Contributor

But we can support system event topic to push event by json format.

make sense.

@mattisonchao
Copy link
Member

@liweiv @liangyuanpeng @Technoboy-

Ok, I will submit a MIP.

@tsturzl
Copy link
Contributor

tsturzl commented Dec 1, 2023

@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: #943

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

5 participants