mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

feat: update mosquitto strings

Open Its-Just-Nans opened this issue 4 months ago • 5 comments

  • [x] Have you signed the Eclipse Contributor Agreement, using the same email address as you used in your commits?
  • [x] Do each of your commits have a "Signed-off-by" line, with the correct email address? Use "git commit -s" to generate this line for you.
  • [x] If you are contributing a new feature, is your work based off the develop branch?
  • [x] If you are contributing a bugfix, is your work based off the fixes branch?
  • [x] Have you added an explanation of what your changes do and why you'd like us to include them?
  • [x] Have you successfully run make test with your changes locally?

Hello

  • Add the correct connack codes (add fixes the usage of it)
  • Add a function for disconnect

Its-Just-Nans avatar Aug 16 '25 02:08 Its-Just-Nans

Codecov Report

:x: Patch coverage is 92.03540% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
apps/mosquitto_ctrl/client.c 0.00% 2 Missing :warning:
client/pub_client.c 0.00% 2 Missing :warning:
client/sub_client.c 0.00% 2 Missing :warning:
lib/cpp/mosquittopp.cpp 0.00% 2 Missing :warning:
client/rr_client.c 0.00% 1 Missing :warning:
Files with missing lines Coverage Δ
lib/srv_mosq.c 0.00% <ø> (ø)
libcommon/strings_common.c 100.00% <100.00%> (ø)
client/rr_client.c 74.19% <0.00%> (ø)
apps/mosquitto_ctrl/client.c 76.56% <0.00%> (+2.32%) :arrow_up:
client/pub_client.c 81.42% <0.00%> (+0.46%) :arrow_up:
client/sub_client.c 78.62% <0.00%> (+0.59%) :arrow_up:
lib/cpp/mosquittopp.cpp 76.34% <0.00%> (-0.64%) :arrow_down:
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Aug 16 '25 02:08 codecov[bot]

I don't think I agree with this change. Could you explain what problem you believe it to be solving?

ralight avatar Aug 24 '25 22:08 ralight

I don't think I agree with this change. Could you explain what problem you believe it to be solving?

mosquitto_connack_string() is incorrect for the MQTT v5 as it currently handle only code from 0 to 5

https://github.com/eclipse-mosquitto/mosquitto/blob/77868330e14e272fc69a54aa1bc29534bfb538cb/libcommon/strings_common.c#L148-L166

Currentlyt, to get the string of a connack code, we should do

  • mosquitto_connack_string() for MQTTv3
  • mosquitto_reason_string() for MQTTv5

And it's also not documented if I'm correct - only as comment here https://github.com/eclipse-mosquitto/mosquitto/blob/77868330e14e272fc69a54aa1bc29534bfb538cb/examples/subscribe/basic-1.c#L17-L20

This fix, update the mosquitto_connack_string for both

  • MQTTv3 3.2.2.3 Connect Return code on https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html
  • MQTTv5 3.2.2.2 Connect Reason Code on https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901079

Also I've added strings for disconnect code translation using mosquitto_disconnect_string() for the 3.14.2.1 Disconnect Reason Code on https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901208 also adding test, and fixing examples

Its-Just-Nans avatar Aug 24 '25 22:08 Its-Just-Nans

Ah, thank you I understand. I believe the answer is to better document it then. There is no such thing as a connack code/string in MQTT v5.0, and no such thing as a reason code/string in MQTT v3.1.1, so mixing the two doesn't make sense to me.

ralight avatar Aug 24 '25 22:08 ralight

Hum that's strange because on MQTTv5 (https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html) I see

  • 2.4 Reason Code
  • 3.2.2.2 Connect Reason Code

On MQTTv3 I see

  • 3.2.2.3 Connect Return code

On MQTTv5, the codes from 2.4 have a general name e.g

Paragraph code
2.4 Reason Code 155 - 0x9B - QoS not supported
3.2.2.2 Connect Reason Code 155 - 0x9B - QoS not supported - The Server does not support the QoS set in Will QoS.
3.14.2.1 Disconnect Reason Code 155 - 0x9B - QoS not supported - The Client specified a QoS greater than the QoS specified in a Maximum QoS in the CONNACK.

What do you think about the mosquitto_disconnect_string()?

What do you think about the mosquitto_connack_string() handling also MQTTv5 code? For example if(code > 5) return mosquitto_reason_string(code)

I can also edit the documentation if needed

Its-Just-Nans avatar Aug 24 '25 23:08 Its-Just-Nans