How to publish a message to a specific client in Mosquitto MQTT

JLT

Currently we have an app that controls multiple devices through MQTT. Each device subscribes to a unique topic which is named after their device ID. For example, device A has device ID 123 so it will subscribe to topic 123. Then if the app wants to publish control message to device A, then it will publish a topic named 123, which is the device ID of device A.

By doing this, if we have 1000 devices then we will have 1000 topics. This is a really bad design. So we are thinking that maybe we can publish a topic to a specific client by setting the client ID that will receive the topic since each client that connects to the broker will have to set a client ID. However, we did not find any method that allows publishing to a specific client. And it seems that MQTT doesn't handle such thing. It only publishes to clients subscribing to the same topic.

So, is there any other way that we can do to to achieve one topic, but still able to publish message to specific clients?

Thanks!

hardillb

There is no way to publish a message to a single subscriber at the MQTT protocol level.

One of the key tenants of a pub/sub system is to totally decouple the publisher from the subscribers, there is no way for a publisher to know if there are any subscribers to a given topic let alone target one specifically.

Using a topic for each device is not a problem as their is virtually no overhead in the broker for each topic. You can also use ACLs to ensure that each client can only subscribe their own topic (while still being able to publish to others if needed)

You could use a single topic that all clients subscribe to and encode the target device in the payload and have the device decide if the message is for it's self. The down side to this is that you can't apply ACLs to this model.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Mosquitto: published mqtt message not delivered to websockets client

From Dev

How to disable mqtt duplicate message in Mosquitto

From Dev

How to use client id in Mosquitto MQTT?

From Dev

How to use mosquitto_pub to publsih the topic/message with specific time interval on the mqtt server?

From Dev

MQTT Android Mosquitto client

From Dev

How to connect to Amazon MQ Broker with Mosquitto MQTT Client

From Dev

How to connect from MQTT javascript client to Mosquitto Server?

From Dev

Publish/Subscribe MQTT message over RabbitMQ using pika (python client)

From Dev

How to store messages in /mosquitto/data MQTT mosquitto?

From Dev

Publish and subscribe to MQTT topics using MQTT.js and Mosquitto

From Dev

Mosquitto MQTT broker with TLS - client connection errors

From Dev

how to publish MQTT messages concurrently using java client?

From Dev

MQTT publish subscribe in the same client

From Dev

Mosquitto publish message format to android app

From Dev

Can ZMQ publish message to specific client by pub-sub socket?

From Dev

node.js mqtt publish to mosquitto broker from callback

From Dev

MQTT with Mosquitto

From Dev

How to test the python paho mqtt with mosquitto?

From Dev

Mqtt: How to install mosquitto old version

From Dev

Response when publish a mqtt message, QOS 0

From Dev

Publish multiple topics in one message MQTT

From Dev

publish a message every 10 seconds mqtt

From Dev

MQTT paho - no error when failed to publish message

From Dev

Spring MVC + Mosquitto + MQTT Integration can't get any message

From Dev

Display the json message from an mqtt server on my terminal (mosquitto)

From Dev

Paho MQTT (C++) client fails to connect to Mosquitto

From Dev

cannot connect to "mqtt://test.mosquitto.org" from React client

From Dev

Issues connecting to mosquitto broker with node mqtt client via SSL/TLS

From Dev

Setup Java MQTT client with Mosquitto over SSL with a self signed certificate

Related Related

  1. 1

    Mosquitto: published mqtt message not delivered to websockets client

  2. 2

    How to disable mqtt duplicate message in Mosquitto

  3. 3

    How to use client id in Mosquitto MQTT?

  4. 4

    How to use mosquitto_pub to publsih the topic/message with specific time interval on the mqtt server?

  5. 5

    MQTT Android Mosquitto client

  6. 6

    How to connect to Amazon MQ Broker with Mosquitto MQTT Client

  7. 7

    How to connect from MQTT javascript client to Mosquitto Server?

  8. 8

    Publish/Subscribe MQTT message over RabbitMQ using pika (python client)

  9. 9

    How to store messages in /mosquitto/data MQTT mosquitto?

  10. 10

    Publish and subscribe to MQTT topics using MQTT.js and Mosquitto

  11. 11

    Mosquitto MQTT broker with TLS - client connection errors

  12. 12

    how to publish MQTT messages concurrently using java client?

  13. 13

    MQTT publish subscribe in the same client

  14. 14

    Mosquitto publish message format to android app

  15. 15

    Can ZMQ publish message to specific client by pub-sub socket?

  16. 16

    node.js mqtt publish to mosquitto broker from callback

  17. 17

    MQTT with Mosquitto

  18. 18

    How to test the python paho mqtt with mosquitto?

  19. 19

    Mqtt: How to install mosquitto old version

  20. 20

    Response when publish a mqtt message, QOS 0

  21. 21

    Publish multiple topics in one message MQTT

  22. 22

    publish a message every 10 seconds mqtt

  23. 23

    MQTT paho - no error when failed to publish message

  24. 24

    Spring MVC + Mosquitto + MQTT Integration can't get any message

  25. 25

    Display the json message from an mqtt server on my terminal (mosquitto)

  26. 26

    Paho MQTT (C++) client fails to connect to Mosquitto

  27. 27

    cannot connect to "mqtt://test.mosquitto.org" from React client

  28. 28

    Issues connecting to mosquitto broker with node mqtt client via SSL/TLS

  29. 29

    Setup Java MQTT client with Mosquitto over SSL with a self signed certificate

HotTag

Archive