Implementation of publishing messages to broker
Closed this issue · 9 comments
How to publish message from app to the mqtt broker?
mqttClient.publish(message)
mqttClient.publish(new Message(new Message({
destinationName: "topic",
payloadString: "data to send"
}));
i'll definitely try this out.. If got all this working, is it okay that I will update readme to help others? :)
Sure, you're welcome to submit a PR :)
in the above code, I think new Message was duplicated causing the mqtt connection to close. But I got it working with this,
this.mqtt_client.publish(new Message({
destinationName: "PubMonitor",
payloadString: "data to send"
}));
The first line was just showing what method to call, the code you used is correct :)
They're all part of the mqtt spec:
payloadBytes sends raw bytes instead of a string
qos: http://www.hivemq.com/blog/mqtt-essentials-part-6-mqtt-quality-of-service-levels
retained: http://www.hivemq.com/blog/mqtt-essentials-part-8-retained-messages
very much explained.. thank you <3
Thanks @edusperoni for this amazing plugin. I struggled for days. I guess a documentation update will solve this issue for others.