You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A publisher publish a retained message, after that a subscriber subscribe to the same topic and should receive the retained message despite at wire level the publish happens.
馃敩 How To Reproduce
Steps to reproduce the behavior:
Run the next test code
Code sample
@Testpublicvoidtest() throwsException {
// connect a publisherfinalMqtt5BlockingClientpublisher = com.hivemq.client.mqtt.MqttClient.builder()
.useMqttVersion5()
.identifier("publisher")
.serverHost("localhost")
.serverPort(1883)
.buildBlocking();
Mqtt5ConnectconnectRequest = Mqtt5Connect.builder()
.cleanStart(true)
.build();
assertEquals(Mqtt5ConnAckReasonCode.SUCCESS, publisher.connect(connectRequest).getReasonCode(), "publisher connected");
// publish a retained message on topic metric/temperature/livingpublisher.publishWith()
.topic("metric/temperature/living")
.payload("18".getBytes(StandardCharsets.UTF_8))
.retain(true)
.qos(MqttQos.AT_LEAST_ONCE)
.send();
// connect a subscriber to the same topicfinalMqtt5BlockingClientsubscriber = com.hivemq.client.mqtt.MqttClient.builder()
.useMqttVersion5()
.identifier("subscriber_with_retain_as_published")
.serverHost("localhost")
.serverPort(1883)
.buildBlocking();
assertEquals(Mqtt5ConnAckReasonCode.SUCCESS, subscriber.connect().getReasonCode(), "subscriber_with_retain_as_published" + " connected");
subscriber.subscribeWith()
.topicFilter("metric/temperature/living")
.qos(MqttQos.AT_LEAST_ONCE)
.send();
// publish reaches the subscriber and also retain flag should be truetry (Mqtt5BlockingClient.Mqtt5Publishespublishes = subscriber.publishes(MqttGlobalPublishFilter.ALL)) {
Optional<Mqtt5Publish> publishMessage = publishes.receive(2, TimeUnit.SECONDS);
if (!publishMessage.isPresent()) {
fail("Expected to receive a publish message");
return;
}
Mqtt5Publishmsg = publishMessage.get();
finalStringpayload = newString(msg.getPayloadAsBytes(), StandardCharsets.UTF_8);
assertEquals("18", payload, "Shared message must be received");
assertEquals(MqttQos.AT_LEAST_ONCE, msg.getQos());
assertTrue(msg.isRetain(), "Publish must be retained also if the subscription 'retain as published' is set to 1");
}
}
Environment
Where are you running/using this client?
On embedded test
Hardware or Device?
not important
What version of this client are you using?
1.3.3
JVM version?
Adoptium 17
Operating System?
MacOS
Which MQTT protocol version is being used?
MQTT 5
Which MQTT broker (name and version)?
Moquette 0.18-SNAPSHOT
Screenshots
馃搱 Expected behavior
Once a subscriber subscribe to a topic that matches a previously retained message, when the PUB message reaches the client, than that message should be pushed to the listener.
馃悰 Bug Report
A publisher publish a retained message, after that a subscriber subscribe to the same topic and should receive the retained message despite at wire level the publish happens.
馃敩 How To Reproduce
Steps to reproduce the behavior:
Run the next test code
Code sample
Environment
Where are you running/using this client?
On embedded test
Hardware or Device?
not important
What version of this client are you using?
1.3.3
JVM version?
Adoptium 17
Operating System?
MacOS
Which MQTT protocol version is being used?
MQTT 5
Which MQTT broker (name and version)?
Moquette 0.18-SNAPSHOT
Screenshots
馃搱 Expected behavior
Once a subscriber subscribe to a topic that matches a previously retained message, when the PUB message reaches the client, than that message should be pushed to the listener.
馃搸 Additional context
pcap that demonstrate that the publish reaches the client.
pub_retained.pcapng.gz
The text was updated successfully, but these errors were encountered: