0

If subscriber has topic as $share/group/my_topic, it doesn't receive any messages, but if I change the topic to /my_topic - everything works just fine.

It seems that M2Mqtt doesn't support shared subscriptions. Is there a workaround for this? I also need persistence to work with shared subscriptions.

If there's no workaround, offers to other libraries are welcome!

tsvedas
  • 1,049
  • 7
  • 18

2 Answers2

1

I can't test this but I have a theory.

The problem is that you have a leading / on your base topic /my_topic

If you remove this and publish messages on my_topic then the shared topic should match.

Having a leading / adds a null element to the topic, which you can't include in the $share/group/[null]/my_topic

While leading a / is allowed in the MQTT spec it is considered bad practice (and can lead to issues like this).

Also the client library has no knowledge of shared subscriptions, this is entirely a broker side feature. All clients should "just work"

hardillb
  • 54,545
  • 11
  • 67
  • 105
0

Use MQTTnet library

It can be found at https://github.com/chkr1011/MQTTnet or as NuGET package.
It does the job, as far as I've tested!

hardillb
  • 54,545
  • 11
  • 67
  • 105
tsvedas
  • 1,049
  • 7
  • 18