Not possible to implement efficient chat

39 views
Skip to first unread message

Alex Hultman

unread,
May 26, 2017, 4:40:34 AM5/26/17
to MQTT
I've done quite the digging in MQTT and I have found one major flaw: you cannot implement an efficient chat.

Imagine N users in a chat room. Each connection is subscribed to the chat room and publishes messages to it. Now, you don't want the sender of a message to receive it from the chat room (that would be 1 extra send, not needed since the sender already knows what it sent).

There is no way to specify that a publish should be sent to everyone EXCEPT the sender. There is also no way to subscribe to a set of topics EXCEPT one. So if we want to solve this by having each user be its own topic, and have every other user subscribe to all other clients topics (which is incredibly inefficient), you get tremendous amounts of subscribe/unsubscribe overhead and it simply doesn't scale.

What the standard needs is:

* Publish flags that specify "exclude the sender if he is subscriber" (this is the behavior of Socket.IO and many others).
* XOR-wildcards (all-but-one): chatRoom/~client1 (same as chatRoom/#, but not including client1)

MQTT already works fine if you have producer and consumer separate like a sensor and a monitor, but as soon as you want to make things like a chat where you have the producer and the consumer overlap there is no efficient way to express this. I have asked many people and they have no good answer to this problem even though it is a no-brainer example of pub/sub.

Rahul Gupta

unread,
May 26, 2017, 10:04:37 AM5/26/17
to mq...@googlegroups.com
Alex - This topic had been discussed in the MQTT v5 OASIS TC and is resolved using JIRA MQTT-235. https://issues.oasis-open.org/browse/MQTT-235
I would recommend you have a look at WD-13 of MQTT-v5 https://www.oasis-open.org/committees/download.php/60716/mqtt-v5.0-wd13.pdf


Kind Regards,
Rahul Gupta

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Alex Hultman

unread,
May 26, 2017, 5:25:07 PM5/26/17
to MQTT
Thanks Rahul,

I have asked this question to a couple of MQTT "experts" and they all just passively pointed towards using more topics "and that's that" (which of course is a play-doh solution). This new MQTT v5 should solve this in a more efficient way.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages