0

I am trying to implemented shared topic concept using Nodejs code.
Now I am planning to implement Topic Alias using the Nodejs Code.

I have tried with below code but I didn't get proper out:

const mqtt = require('mqtt')
const clientThree = mqtt.connect('mqtt://192.168.x.xx:1883')
var options={
    topicAliasMaximum:1,
};
clientThree.on('connect', () => {
    let i = 0
        clientThree.publish('test', "hello",options);

})
pujara
  • 21
  • 1
  • 8
  • please suggest anybody here. – pujara Jun 18 '19 at 05:56
  • I know the question is old, but it's still really not clear what you were asking. Tell us how it does not work, what wrong output you get, any error messages, what you would expect, etc. [How to ask](https://stackoverflow.com/help/how-to-ask) – joanis Aug 11 '19 at 02:22

1 Answers1

0

Shared topic is share topic prefix + topic like:

# single topic
t/#
# share topic
$queue/t/#
# or
$share/group1/t/#

Topic Alias is the property of MQTT 5.0, See mqtt.js properties options:

const client = mqtt.connect({
  properties: {
    topicAliasMaximum: 10
  }
})

// Now sub topic and set the topic subscription id
client.subscribe('t/#', { properties: { subscriptionIdentifier: 2 } })

// Now using subscription id to publish
// wait me try..
wivwiv
  • 255
  • 1
  • 3