Waits until there is at least one message in the inbox.

C Language

size_t mqtt_await_messages( MQTT handle, int timeoutMsec);

ExampleMQTT Vuser Functions


handleThe MQTT client handle returned by mqtt_create.
timeoutMsecNumber of milliseconds or MQTT_DEFAULT.
Default: The timeout value in the runtime settings.


mqtt_await_messages waits until there is at least one message in the inbox. The script run continues after there is a message or after the wait times out.

If invalid arguments are passed, the Vuser aborts, even if Continue on error is set.

Return Values

The number of messages in the inbox. 0 if timed out.


Standard parameterization is not available for this function.


// wait for messages to arrive and print the message count

size_t messageCount = mqtt_await_messages(client, MQTT_DEFAULT);

lr_message("There are %d pending messages", messageCount);

if (messageCount > 0) {

// handle messages