Skip to main content

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

This will work as an example to prove it work, assuming you've got the
mosquitto clients available.

In one command line window:

mosquitto_sub -h test.mosquitto.org -t unimportant --will-topic
lastwill --will-payload "I am offline" --will-qos 1

In a second window:

mosquitto_sub -h test.mosquitto.org -t lastwill -v

Then press Ctrl-C in the first window.

Assuming that works, do the same thing with the server you are running
to narrow down where the problem is.

Cheers,

Roger

On Sat, Aug 24, 2013 at 10:13 AM, 灰(Grey)狼 <86267306@xxxxxx> wrote:
> 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(){...}
>
>
>
>
>
>
>
> _______________________________________________
> paho-dev mailing list
> paho-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/paho-dev
>


Back to the top