Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is mqtt support both one to many and many to one?

Tags:

mqtt

Recently I had read an iot article http://www.eclipse.org/community/eclipse_newsletter/2014/february/article2.php In this he is saying that, by mqtt protocol clients can communicate both in one to many and many to one ways. In the mqtt spec itself mentioning about the one to many but I had little confusion in many to one. What I understood is, many clients are publishing on same topic and there is only one subscriber for these different publishers.Then how the subscriber(user) should identify message belongs to which publisher? Another doubt, if two publishers used the same topic to publish their data without knowing each other, because of every client is connected to the internet, the subscriber will get both the datas. But that is not what the subscriber expected.He wants data from only one publisher. Is there any chance to occur the same scenario in mqtt communication?

like image 714
user2995743 Avatar asked Sep 12 '15 15:09

user2995743


People also ask

Is MQTT a two way?

MQTT is a publish and subscribe protocol with no direct connection between clients. However many applications require a client to client type connection.

Is MQTT one way?

Introduction: Using the MQTT (Message Queuing Telemetry Transport) broker, the user should be able to create an MQTT connection using one-way authentication (only MQTT server authenticates via the certificate).

How many connections can MQTT handle?

Each one will handle 10-20 clients. As far as I understand a common solution is MQTT. The clients periodically send data to the broker (i.e. Mosquitto running on the hosting server), that in turn updates the main web app that runs on the same server.

Can MQTT subscribe to multiple topics?

Subscribing to Multiple MQTT Topics You can subscribe by: Calling the subscribe function for each topic. Calling the subscribe function with a topic list.


1 Answers

Here are some facts about MQTT that will perhaps help you understand.

  1. A publisher does not "own" a topic. A publisher may choose to publish a message to ANY topic (assuming it is a valid MQTT topic).

  2. Given point 1 above, any number of publishers may simultaneously publish to the same topic.

  3. A client can choose to subscribe to specific or wildcarded topics to receive information published from any publisher.
  4. A client can be both a publisher and subscriber (it would even be possible for a client to receive its own published message).
  5. The MQTT Broker takes care of managing all relationships between clients. Clients dot not know (or care) which other clients are currently connected to the broker. Publishers and subscribers are completely decoupled although they may communicate using MQTT capabilities (pub/sub).
  6. It is possible that a publisher's message is discarded because no subscribers are currently interested in that message. (e.g.: publisher publishes to topic "topic1". If no subscribers had previously requested a subscription to "topic1", the message will be discarded by the MQTT broker since it has no client to send it to).
  7. A single publisher can publish to multiple clients at once. (e.g.: 10 clients come online and request a subscription to topic "topic1". Another client comes online and publishes to "topic1". All 10 subscribers to "topic1" will receive the message. The publisher simply had to publish one message to the MQTT broker, the MQTT broker is responsible for relaying the message to all 10 subscribers).

Hopefully these tidbits of information will help you understand, please let me know if I anything is still unclear.

like image 181
Pierre-Luc Avatar answered Sep 20 '22 09:09

Pierre-Luc