Describe the bug
When connecting to a (nanomq) broker with the mqttv5_client demo program (sub subcommand), it chokes on the CONNACK packet because there's this assert in the receive path that only allows PUBLISH packets:
Replacing the assert by a check for PUBLISH and a branch that just frees the message in case it is not a PUBLISH message solves the issue (via printf(), I determined that the violating packet was a CONNACK packet).
Expected behavior
The subscription use of mqttv5_client (see in section about reproduction below) succeeds and receives changes.
Actual Behavior
The subscription use of mqttv5_client exits in the following way:
root@xxx:/data/nng# ./mqttv5_client sub mqtt-tcp://127.0.0.1:1883 0 foo
Connecting to server ...
connect_cb: connected! RC [0]
Start receiving loop:
mqttv5_client: /home/xxx/nng/demo/mqttv5/mqttv5_client.c:460: main: Assertion
`nng_mqtt_msg_get_packet_type(msg) == NNG_MQTT_PUBLISH' failed.
Aborted
To Reproduce
Start nanomq
Start a periodic publishing task: ./mqttv5_client pub mqtt-tcp://127.0.0.1:1883 0 foo "bar" 1000 1
Start a subscriber for this topic: ./mqttv5_client sub mqtt-tcp://127.0.0.1:1883 0 foo
Describe the bug When connecting to a (nanomq) broker with the
mqttv5_client
demo program (sub
subcommand), it chokes on theCONNACK
packet because there's this assert in the receive path that only allowsPUBLISH
packets:Replacing the assert by a check for PUBLISH and a branch that just frees the message in case it is not a
PUBLISH
message solves the issue (viaprintf()
, I determined that the violating packet was aCONNACK
packet).Expected behavior The subscription use of
mqttv5_client
(see in section about reproduction below) succeeds and receives changes.Actual Behavior The subscription use of
mqttv5_client
exits in the following way:To Reproduce Start nanomq Start a periodic publishing task:
./mqttv5_client pub mqtt-tcp://127.0.0.1:1883 0 foo "bar" 1000 1
Start a subscriber for this topic:./mqttv5_client sub mqtt-tcp://127.0.0.1:1883 0 foo
Environment Details
Additional context n/a