eclipse-paho / eclipse-paho/paho.mqtt.java
Subscribing to connectionLost outside default MqttCallback
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 919
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I was wondering: is it possible to subscribe to the "connectionLost" event without setting the default message listener (i.e. mqttClient.setCallback(new MqttCallback() ...)?
I am asking because I subscribing to the topics using the "subscribe(topic, qos, IMqttMessageListener)" function. I noticed that, having set CleanSession=false, all pending qos>0 messages will be delivered right after being connected (to the default MqttCallback), but before I have the chance to call the subscribe functions (where I have assigned the handling functions). I also cannot subscribe before the connection is established, otherwise exceptions will be thrown because the "client is not connected". I am not sure if this is an expected behavior, so I was wondering how to be able to use IMqttMessageListener subscriptions and yet still be notified when a connection is lost.
Contributor guide
Assessment
This issue has not been assessed yet.