Closed andsel closed 12 months ago
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 :+1:
How can it stay connected in the background all the time? After a while, I get a disconnect error.
Checklist
issues
.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: https://github.com/hivemq/hivemq-mqtt-client/blob/338f33877d72dc71d0e9c528c7f80ba15096b32c/src/main/java/com/hivemq/client/internal/mqtt/codec/encoder/mqtt5/Mqtt5ConnectEncoder.java#L306-L316
and the
willPublish
instance comes from the MqttConnect message: https://github.com/hivemq/hivemq-mqtt-client/blob/338f33877d72dc71d0e9c528c7f80ba15096b32c/src/main/java/com/hivemq/client/internal/mqtt/message/connect/MqttConnect.java#L119-L121which accepts it as its parameters in the constructor https://github.com/hivemq/hivemq-mqtt-client/blob/338f33877d72dc71d0e9c528c7f80ba15096b32c/src/main/java/com/hivemq/client/internal/mqtt/message/connect/MqttConnect.java#L73
https://github.com/hivemq/hivemq-mqtt-client/blob/338f33877d72dc71d0e9c528c7f80ba15096b32c/src/main/java/com/hivemq/client/internal/mqtt/message/connect/MqttConnectBuilder.java#L135-L138
the
willPublish
comes from theMqttConnect
which is built by theMqtt5Connect.builder()
. That builder provides awillPublish
method but theMqtt5WillPublishBuilder.Nested
doesn't provide any method to set thewill delay interval
property.Please could you provide a sample, or code snippet to do this?
My sample test code:
Thank's a lot :-)