Go Down

Topic: MQTT Last Will (Read 3339 times) previous topic - next topic


Jun 01, 2019, 06:52 pm Last Edit: Jun 01, 2019, 06:53 pm by Epircus
I bought a Huzzah ESP8266 which I'm using to control an LED strip through a web client.

I implemented a rabbitmq mqtt server on a raspberry pi.

I started out using the PubSubClient library for mqtt. Everything was going pretty smoothly until I tried sending a Last will message that would be retained.

Code: [Select]
byte willQoS = 0;
const char* willTopic = "tv/pixel/status";
const char* willMessage = "turn off";
boolean willRetain = true;

client.connect("Pixel", "username", "password", willTopic, willQoS, willRetain, willMessage);

Which results in the payload being sent on timeout but it does not retain. I'm at a loss I've tried changing the variable around, looked through the .cpp library but I don't know enough about mqtt and C++ to solve it

If this is a bug is there any other mqtt libraries out for arduino/esp8266 that I can send last will messages that can be retained?


The mqtt server/broker is responsible for retaining and sending the LW message when needed.

Search the rabbitmq code repo issues. Or try a different mqtt broker such as mosquitto.


Jun 14, 2019, 10:24 pm Last Edit: Jun 14, 2019, 10:27 pm by Romonaga
The point of last will from what I remember is to send notification when a disconnect occurs that is not orderly.

I think what you are looking to do is have a message retained at the broker.

A retained message will stay in the broker until a new message arrives or. Message is sent with no payload.


Go Up