MQTT and LastWillTestament
Antwort
11.09.19 05:44

I want to have a LastWillTestament on my MQTT Broker. So when the XDK gets turned off or the battery is empty, that the MQTT Broker sends a message on the predefined Topic, saying that the XDK didn't properly disconnect itself.

This is the related sourecode:

SessionPtr->MQTTVersion = 4;
SessionPtr->keepAliveInterval = 100;
SessionPtr->cleanSession = true;
SessionPtr->will.haveWill = true;

StringDescr_T mqttWillTopic;
StringDescr_wrap(&mqttWillTopic, MQTT_Will_TOPIC);
SessionPtr->will.topic = mqttWillTopic;

StringDescr_T mqttWillMessage;
StringDescr_wrap(&mqttWillMessage, MQTT__Will_MESSAGE);
SessionPtr->will.message = mqttWillMessage;

//MQTT_Will_TOPIC defines the Topic on which is send
//MQTT_Will_MESSAGE defines the send message

 

Whats happening is:

Once the XDK is turned off, nothing happens. When you turn the XDK back on the Error Message is send on the related topic, but only AFTER you turned the XDK back on.

Any ideas why it's not sent right ater turning the XDK off?

0 (0 Stimmen)
RE: MQTT and LastWillTestament
Antwort
12.09.19 12:20 als Antwort auf Martin Scheck.

Hi Martin,

I have two hypothesis on why your Last-Will-And-Testament message was not sent by the broker

  1. The message was not registered by your XDK
  2. The broker did not notice the disconnection event

 

Regards,

Francisco

 

 

0 (0 Stimmen)
RE: MQTT and LastWillTestament
Antwort
13.09.19 13:06 als Antwort auf Francisco Llobet Blandino.

Hi Francisco,

I think I can excluce your first hypothesis. I'm listening to the Topic with the program MQTT.fx where i monitor all messages going through the Broker on every topic. And as I said, the LastWillTestament message is only send after the XDK is turned back on and builds a session with the MQTT Broker.

Therefore I think your second hypothesis should be fitting. But that sadly doesn't help me much. And I dont think its a fault of the Broker, because i with a simple html website that ran javascript and the following library and example: https://www.eclipse.org/paho/clients/js/ and when I closed the website it regularly send the LastWill Message.

So it's not the brokers fault either. The only thing that comes to my mind is that the broker specifically doesnt get the disconnection event of the XDK.

Or something with the MQTT configuration on the XDK side is broken.

 

Any ideas on how to fix this issue?

0 (0 Stimmen)