How to set MQTT5 WILL_DELAY_INTERVAL property?
andsel opened this issue ยท 4 comments
Checklist
- I've searched the project's
issues
. - I've searched the project's
discussions
.
โ Question
How I can set the MQTT5 WILL_DELAY_INTERVAL
Connect's property?
๐ Additional context
I'm trying to connect with a custom will delay interval. Looking at the code the property in the connect message is encoded:
and the willPublish
instance comes from the MqttConnect message:
which accepts it as its parameters in the constructor
the willPublish
comes from the MqttConnect
which is built by the Mqtt5Connect.builder()
. That builder provides a willPublish
method but the Mqtt5WillPublishBuilder.Nested
doesn't provide any method to set the will delay interval
property.
Please could you provide a sample, or code snippet to do this?
My sample test code:
final Mqtt5BlockingClient publisher = MqttClient.builder()
.useMqttVersion5()
.identifier("simple_client")
.serverHost("localhost")
.serverPort(1883)
.buildBlocking();
Mqtt5Connect connectMessage = Mqtt5Connect.builder()
.keepAlive(10)
.willPublish()
// here I miss the ability
.build();
Mqtt5ConnAck connectAck = publisher.connect(connectMessage);
Thank's a lot :-)
I'm using client version 1.3.1
but same with 1.3.0
Hi @andsel
The option is only present after you specified the mandatory topic:
Mqtt5Connect connectMessage = Mqtt5Connect.builder()
.keepAlive(10)
.willPublish()
.topic("test")
.delayInterval(123)
.applyWillPublish()
.build();
Thank's @SgtSilvio, I missed that builder changed after topic
invocation ๐
How can it stay connected in the background all the time? After a while, I get a disconnect error.