Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT.js and shared subscriptions #789

Open
jkinghed opened this issue Mar 7, 2018 · 10 comments
Open

MQTT.js and shared subscriptions #789

jkinghed opened this issue Mar 7, 2018 · 10 comments

Comments

@jkinghed
Copy link

jkinghed commented Mar 7, 2018

Several MQTT brokers are now supporting shared subscriptions (HiveMQ, VerneMQ, EMQ) from the v5 MQTT standard.

The syntax of subscribing to a shared topic seem currently differs based on broker:

HiveMQ
$share:sharename:topic/subtopic/etc (details)

VerneMQ
$share/sharename/topic/subtopic/etc (details)

EMQ
$queue/topic/subtopic/etc
or
$share/sharename/topic/subtopic/etc
(details)

The MQTT v5 standard specifies
$share/sharename/topic/subtopic/etc (details)

So, at least VerneMQ and EMQ both works with the standard.

Any messages published to topic topic/subtopic/etc should then be distributed by the broker to the different subscribers using the $share/sharename/topic/subtopic/etc subscription, but only 1 of the subscribers will get the message. (Which subscriber depends on broker and settings.)

Using this feature makes load balancing very easy.

However, it seems MQTT.js does not yet support this as messages published to a topic with shared subscriptions from MQTT.js are ignored.

Are there any plans to implement this?

@mcollina
Copy link
Member

mcollina commented Mar 7, 2018

Are there any plans to implement this?

Would you like to contribute? See #651 .

@jkinghed
Copy link
Author

jkinghed commented Mar 8, 2018

Not sure I have the required skills, but I'll try to find time to look into it. Thanks.

@markusapfler
Copy link

Is there any progress on the implementation of this feature?

@jkinghed
Copy link
Author

jkinghed commented Apr 3, 2019

Is there any progress on the implementation of this feature?

It has been implemented in Node-Red - source - which uses MQTT.js.

The issue is that MQTT.js default client treats $share/sharename/topic/subtopic/etc as a literal topic, so when something is published on topic/subtopic/etc it is ignored, as the subscription is for $share/sharename/topic/subtopic/etc

However, in Node-Red - and I'm not sure I'm correct on the sequence of things here - it seems that the handler for the subscription overrides the default and validates each message against the actual topic without $share/sharename/ prefix. code

So if you were to do something similar in your client, you might get it to work...

@Paic
Copy link

Paic commented Dec 2, 2019

Hey 👋
We had this problem today (can't remember the version, I'll update my post later) and I just tested right now with package version 3.0.0 and it looks like everything is fine (using VerneMQ, even though it doesn't really matter).

Can someone confirm this is fixed ?

@github-actions
Copy link

This is an automated message to let you know that this issue has
gone 365 days without any activity. In order to ensure that we work
on issues that still matter, this issue will be closed in 14 days.

If this issue is still important, you can simply comment with a
"bump" to keep it open.

Thank you for your contribution.

@github-actions github-actions bot added the stale label Sep 27, 2022
@github-actions
Copy link

This issue was automatically closed due to inactivity.

@SaumilShah-7
Copy link

Unable to use shared subscription in the latest version of MQTT.js. Client keeps subscribing in loop and doesn't consume any message. Will this be supported or is there a work-around ?

@fp-caregility
Copy link

Unable to use shared subscription in the latest version of MQTT.js. Client keeps subscribing in loop and doesn't consume any message. Will this be supported or is there a work-around ?

I am also seeing this behavior. Did you find a solution?

@robertsLando
Copy link
Member

Could someone share a minumum reproduction script?

@robertsLando robertsLando reopened this Feb 13, 2024
@github-actions github-actions bot removed the stale label Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants