Skip to content

Commit

Permalink
fix: Wait for MQTT subscriptions to take effect before returning (#516)
Browse files Browse the repository at this point in the history
MQTTAsync_subscribe() is async. There are some places e.g. startConfigured()
where we expect the subscription to be in effect right after this call.
So wait for completion before returning.

Fixes: #516

Signed-off-by: Corey Mutter <[email protected]>
  • Loading branch information
eaton-coreymutter committed Oct 23, 2024
1 parent de2f7dd commit d2bfa6c
Showing 1 changed file with 4 additions and 0 deletions.
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);
}
}

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

0 comments on commit d2bfa6c

Please sign in to comment.