HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
With the automatic reconnect the HiveMQ client will also resubscribe if the session was not present (MqttClientReconnector.DEFAULT_RESUBSCRIBE_IF_SESSION_EXPIRED = true).
Actual behavior
The problem is that if I my initial SUBSCRIBE had user properties I can't add them to the automatic RESUBSCRIBE.
To Reproduce
Steps
start HiveMQ with the message log extension (with verbose true)
run test below, when client is connected -> forcefully disconnect client from server (I used the "Disconnect Client" feature in the Client Detail page of the HiveMQ Control Center)
The message log extension will log all packet information from the client which you can see in the hivemq.log, here an example
2022-07-20 10:39:15,368 INFO - Received CONNECT from client 'test-client': <<<removed>>>, User Properties: [Name: 'test', Value: 'test']
2022-07-20 10:39:15,438 INFO - Received SUBSCRIBE from client 'test-client': <<<removed>>>, User Properties: [Name: 'test', Value: 'test']
2022-07-20 10:39:19,553 INFO - Sent DISCONNECT to client 'test-client': Reason Code: 'ADMINISTRATIVE_ACTION', Reason String: 'null', Server Reference: 'null', Session Expiry: 'null', User Properties: 'null'
2022-07-20 10:39:20,737 INFO - Received CONNECT from client 'test-client': <<<removed>>>, User Properties: [Name: 'test', Value: 'test']
2022-07-20 10:39:20,791 INFO - Received SUBSCRIBE from client 'test-client': <<<removed>>>, User Properties: 'null'
Reproducer code
@Test
public void test() throws Exception {
final Mqtt5UserProperties connectProperties = Mqtt5UserProperties.builder()
.add("test", "test").build();
final Mqtt5AsyncClient client = Mqtt5Client.builder()
.identifier("test-client")
.addDisconnectedListener(context ->
TypeSwitch.when(context.getReconnector())
.is(Mqtt5ClientReconnector.class, mqtt5ClientReconnector -> {
final var builder = mqtt5ClientReconnector.connectWith();
builder.userProperties(connectProperties);
builder.applyConnect();
// client will also resubscribe when session was expired, but I don't have the option to add the properties again
}))
.automaticReconnect()
.applyAutomaticReconnect()
.buildAsync();
client.connectWith().userProperties(connectProperties).send().get();
client.subscribeWith()
.addSubscription()
.topicFilter("test")
.qos(MqttQos.AT_LEAST_ONCE)
.applySubscription()
.userProperties(Mqtt5UserProperties.builder().add("test", "test").build())
.send()
.get();
TimeUnit.MINUTES.sleep(20);
}
}
Details
Affected HiveMQ MQTT Client version(s): 1.3.0
Used JVM version: openjdk version "11.0.13" 2021-10-19 LTS
Expected behavior
With the automatic reconnect the HiveMQ client will also resubscribe if the session was not present (MqttClientReconnector.DEFAULT_RESUBSCRIBE_IF_SESSION_EXPIRED = true).
Actual behavior
The problem is that if I my initial SUBSCRIBE had user properties I can't add them to the automatic RESUBSCRIBE.
To Reproduce
Steps
Reproducer code
Details