I want to test the QoS of the MQTT protocol. I use aedes as my broker.

For testing QoS 2, one of the test cases I'd have to evaluate, is to run a scenario where once a message is published by the client, the broker forwards it to the subscriber who receives the message but the acknowledgement(tcp) and/or the pubrec(mqtt) are not received by the broker. By running such a case, I check that the message is not received twice by the subscriber.

So my plan is, once a message is published by the client to run aedes.authorizePublish broker-side and set a sleep for a couple of seconds and in the meantime to block the IP of the subscriber on the used port(1883).

mqttBroker.authorizePublish = function (client, packet) {
    if (packet.topic === 'hello' && client.id === '01B4C') {
        let PACK = packet;
        setTimeout(function (packet) {
        }, 10000)

Have tried:

netsh advfirewall firewall add rule name="IP Block" dir=in protocol=TCP interface=any action=block remoteip= localport=1883

So I expect that the broker will publish the message to and that no packets from subscriber should be received by the broker until I invert the netsh command with

netsh advfirewall firewall delete rule name="IP Block" remoteip=

In this example I have 2 clients (.109 & .120) and the broker (.13). I have set the publisher of the message (.109) as a subscriber too for testing purposes. Irrelevant for the question, just so that it's not confusing.

So I expected to get packets like that:

Packets when I remove eth cable from subscribed client

But the packets from the image above are the ones I get when I simply remove the eth cable from my subscribed client and put it back in.

The packets I get from the procedure with the netsh commands are:

Packets when I block the ip from subscribed client, only the direction to the broker

My questions are:

  1. Is it a good way to test MQTT QoS like that?
  2. How can I simulate this scenario in an automated way where no cables are removed, of course, and I block one way of the connection?

1 Answer 1


Since what I want to test is not really the connection but how the client responds to undelivered acknowledgements, a possible way to approach this would be, once the broker publishes the message to the client(.120) and the full set of acknowledgement transaction happens, then publishes the same exact message with the addition of the dup flag to 1.

The expected reaction would be the client ignoring this second publish.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.