vernemq / vernemq

A distributed MQTT message broker based on Erlang/OTP. Built for high quality & Industrial use cases. The VerneMQ mission is active & the project maintained. Thank you for your support!
https://vernemq.com
Apache License 2.0
3.24k stars 395 forks source link

Api to send message to a device with its clientid? #1330

Open khoshbin opened 5 years ago

khoshbin commented 5 years ago

Environment

VerneMQ Version: 1.9.2
OS: CentOS 7
Erlang/OTP version (if building from source):
VerneMQ configuration (vernemq.conf) or the changes from the default
Cluster size/standalone: Standalone

I want to know if there is any api to send message directly to a device with its clientid without publishing a message to any topic?

larshesel commented 5 years ago

There isn't at the moment. It is certainly possible to do this from within an Erlang plugin using internal functions, though.

khoshbin commented 5 years ago

Is there any code sample/documentation in this regard? this is not part of mqtt protocol.But some brokers(like IBM's) have internal api to do this.It is great feature to be added to your feature list

larshesel commented 5 years ago

I don't know of any samples for this - you'd have to dig into the code yourself or ask on the community slack if anyone did this already. We'll put the feature on the backlog for future consideration. I'll keep this open for now.

khoshbin commented 5 years ago

EMQ also has this feature and has been implemented with mod_subscription. In this module we can have:

## Subscribe the Topics's qos
## module.subscription.1.topic = $client/%c
## module.subscription.1.qos = 0
larshesel commented 5 years ago

IIUIC that is a way of creating a unique topic which clients are automatically subscribed to - you still need to publish a message to that particular topic using an MQTT client.

khoshbin commented 5 years ago

Yes, this is the tricky part,it gives a temp solution for our needs.But with direct delivery it is excellent. It was even much better if there was also a database counterpart that could store dynamic subscriptions.

larshesel commented 5 years ago

What is your use-case? It's much better to discuss solutions if we understand the problem you're trying to solve.

khoshbin commented 5 years ago

it is push notifications like what you see in Google's Firebase

larshesel commented 5 years ago

ok - I can't rule out if we might implement something like this at some point - but at the moment it is not a priority, as something like this can easily be modeled by each client subscribing to a simple topic like direct/<client-id> or similar.