# \[core\]\[mqtt-in\] Shared Subscriptions for core node MQTT-In (MQTT v5)

**URL:** <https://discourse.nodered.org/t/core-mqtt-in-shared-subscriptions-for-core-node-mqtt-in-mqtt-v5/2475>\
**Category:** Feature Requests\
**Created:** [22 August 2018 11:09 UTC](https://discourse.nodered.org/t/core-mqtt-in-shared-subscriptions-for-core-node-mqtt-in-mqtt-v5/2475 "2018-08-22T11:09:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![loldiges](https://avatars.discourse-cdn.com/v4/letter/l/6a8cbe/32.png) [@loldiges](https://discourse.nodered.org/u/loldiges)\
**Post date:** [22 August 2018 11:09 UTC](https://discourse.nodered.org/t/core-mqtt-in-shared-subscriptions-for-core-node-mqtt-in-mqtt-v5/2475/1 "2018-08-22T11:09:53Z")

</div>

Hi,

this is the first self created topic in this forum, be kind please 😛 :  
Short:

- Assuming a MQTT Broker capable of shared subscriptions
- MQTT.js "supports" shared supscriptions (at least not prevents them)
- The core node "MQTT-In" has a method `matchTopic` that prevents shared subscriptions from working.
- I already fixed it locally, happy to contribute via PR

Extended:  
Shared Subscriptions for MQTT as already implemented by some brokers and defined in [MQTT v5](http://docs.oasis-open.org/mqtt/mqtt/v5.0/cs02/mqtt-v5.0-cs02.html#_Toc514345522):

- subscribe to: `$share/SHARENEMAE/topic`
- publish to: `topic`
- the broker will forward the message to only ONE subsriber (client id) of the topic.

To my understanding the `matchTopic(ts,t)` function in `nodes/core/io/10-mqtt.js` checks if the topic string subscribed to matches the topic string in the received message (including MQTT wildcards etc.).  
With shared subscriptions ts will not match t (`$share/SHARENEMAE/topic` vs. `topic`).

I am not saying this will implement v5 just "not prevent" shared subscriptions.

I will create a PR today.

Any comments?

Best regards  
Lars

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [22 August 2018 12:03 UTC](https://discourse.nodered.org/t/core-mqtt-in-shared-subscriptions-for-core-node-mqtt-in-mqtt-v5/2475/2 "2018-08-22T12:03:16Z")

</div>

Just comment: reading your link - calling them shared subscriptions seems one of the most un-intuitive naming conventions I've ever come across after urban slang bad = good !

[edit] Just found [https://www.hivemq.com/blog/mqtt-client-load-balancing-with-shared-subscriptions/](https://www.hivemq.com/blog/mqtt-client-load-balancing-with-shared-subscriptions/) and I'm a bit more on-board now 🙂 [/edit]

---

<div class="post-metadata">

**Author:** ![loldiges](https://avatars.discourse-cdn.com/v4/letter/l/6a8cbe/32.png) [@loldiges](https://discourse.nodered.org/u/loldiges)\
**Post date:** [22 August 2018 12:50 UTC](https://discourse.nodered.org/t/core-mqtt-in-shared-subscriptions-for-core-node-mqtt-in-mqtt-v5/2475/3 "2018-08-22T12:50:21Z")

</div>

Glad to hear that - I am not a native speaker.. did not notice anything wrong with the name but  
as you see I did not choose the name 🙂

We use VerneMQ right now, they call it shared subscription, hiveMQ does and also the MQTT v5 Specification.  
[https://vernemq.com/docs/configuration/shared\_subscriptions.html](https://vernemq.com/docs/configuration/shared_subscriptions.html)  
[http://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html](http://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html)

No matter the name, it is great for autoscaling clients for example.
