In Android, at the moment when I publish something using MqttAndroidClient
, it waits indefinitely. I want to set a timeout for Publish method, so that I know when it has failed to publish.
Please let me know how to add the timeout.
val mqttClient = MqttAndroidClient(context, BuildConfig.MQTT_URL, clientId, Ack.AUTO_ACK)
val options = MqttConnectOptions()
options.userName = BuildConfig.MQTT_USERNAME
options.password = BuildConfig.MQTT_PASSWORD.toCharArray()
options.isCleanSession = false
options.isAutomaticReconnect = false
mqttClient?.connect(options, object : IMqttActionListener {
override fun onSuccess(asyncActionToken: IMqttToken?) {}
override fun onFailure(asyncActionToken: IMqttToken?, exception: Throwable?) {})
I don't see the function setTimeToWait(timeToWaitInMillis);
which is available for MqttClient