我让他LWT topic
跟着WT message
private final String WILL_TOPIC = "sensor_0_LWT";
private final String WILL_MSG = "LWT: Unexpected Connection Drop Down";
当我发布消息时,我订阅了一个topic
名称sensor_0
,但当我关闭 WiFi 并再次打开它时,我希望看到LWT messahe
我在连接选项中设置的,但发生的情况是我没有收到它.
为什么我重新连接时没有收到LWT
消息?
代码:
final MqttClientPersistence persistenceDataDir = new
MqttDefaultFilePersistence(folder.toString());
final MqttAndroidClient client_1 = new MqttAndroidClient(getApplicationContext(), serverURI,
clientID, persistenceDataDir, Ack.AUTO_ACK);
MqttConnectOptions opts = new MqttConnectOptions();
opts.setCleanSession(false);
opts.setWill(WILL_TOPIC, WILL_MSG.getBytes(), 1, true);
opts.setKeepAliveInterval(keepAliveInterval);