Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] How to receive a "last will" message

Hi,all:

         I am confused how to receive a LWT messsge. I have set a last will in a subscriber A , the last will topic is called "lastwill". and start subscriber B to listen the "lastwill" topic .

         When I make some exception in Subscriber A ,to make the Subscriber disconnect from broker , no message arrived in subscriber B. I noticed some document said Server will
      
         publish the last will message. I spent lots of time and found no answer , any help will be appreciated , thanks.

   mqttClient = new MqttClient("tcp://192.168.100.80:1883", MqttClient.generateClientId());
   

   MqttConnectOptions connectOptions = new  MqttConnectOptions();

   //set will
   connectOptions.setWill(mqttClient.getTopic("lastwill"), new String("I am offline").getBytes(), 1, false);
   mqttClient.connect(connectOptions);
   mqttClient.setCallback(new MqttCallback(){...}

 

 

 

Back to the top