Skip to content

Conversation

@scootermon
Copy link

The following circumstances lead to an error when calling client.try_publish:

  1. The client is configured to allow sending at any time.
  2. The client is set up to use MQTTv5.
  3. The client has not made an attempt to connect yet.

This fails because the Rust side doesn't know the correct MQTT version in this case. It assumes MQTT_VERSION_DEFAULT and ends up using the wrong callback fields when calling MQTTAsync_sendMessage. The C implementation catches this and returns a MQTTASYNC_BAD_MQTT_OPTION error.

I'm not sure if there's a good reason InnerAsyncClient assumes MQTT_VERSION_DEFAULT instead of copying the version from the create options, but as far I can tell that's the solution to this problem.

@scootermon scootermon force-pushed the fix/version-before-connect branch 2 times, most recently from b67f0c7 to 49e227c Compare September 23, 2025 17:02
@scootermon scootermon force-pushed the fix/version-before-connect branch from 49e227c to 306dc25 Compare September 23, 2025 17:04
@fpagliughi
Copy link
Contributor

Yeah, this sounds like a bug. I'll have a look at the PR shortly.

@fpagliughi fpagliughi added this to the v0.13.4 milestone Sep 25, 2025
@fpagliughi fpagliughi added the bug label Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants