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

fix: Wait for MQTT subscriptions to take effect before returning (#516) #517

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/c/bus-mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ static void edgex_bus_mqtt_subscribe (void *ctx, const char *topic)
{
iot_log_error (cinfo->lc, "mqtt: unable to subscribe to %s, error code %d", topic, rc);
}
else
{
MQTTAsync_waitForCompletion(cinfo->client, opts.token, 1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could consider adding a check for the return code of MQTTAsync_waitForCompletion. If the return code is not MQTTASYNC_SUCCESS, logging it could be helpful for diagnosing problems.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eaton-coreymutter Just wanted to confirm the idea of adding a return code check for MQTTAsync_waitForCompletion. What are your thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a good idea, I will add the change soonish, or you are welcome to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eaton-coreymutter I am asking Felix to merge this PR and to open another PR to address his change request

}
}

static void edgex_bus_mqtt_post (void *ctx, const char *topic, const iot_data_t *envelope)
Expand Down