Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mqttv5_client chokes on CONNACK packet #1832

Closed
pmf opened this issue May 7, 2024 · 2 comments
Closed

mqttv5_client chokes on CONNACK packet #1832

pmf opened this issue May 7, 2024 · 2 comments

Comments

@pmf
Copy link

pmf commented May 7, 2024

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:

assert(nng_mqtt_msg_get_packet_type(msg) == NNG_MQTT_PUBLISH);

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

Environment Details

  • NNG version: 6d0fc9ce40df78ce1e6b22e3831278c24f932e95
  • Operating system and version: custom ARM Linux (32 bit armv7hf)
  • Compiler and language used: n/a
  • Shared or static library: n/a

Additional context
n/a

@pmf pmf changed the title mqttv5_client chokes on CONACK packet mqttv5_client chokes on CONNACK packet May 7, 2024
@JaylinYu
Copy link
Contributor

JaylinYu commented May 9, 2024

... This belongs to nanosdk not nNG here. MQTT support is not merged yet

@pmf
Copy link
Author

pmf commented May 13, 2024

OK, I'll make sure to use the NanoSDK examples/demo instead of the nng examples/demos.

@pmf pmf closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants