mqtt_disconnect

Disconnects the MQTT client from the server.

C Language

int mqtt_disconnect( MQTT handle);

ExampleMQTT Vuser Functions

Arguments

NameComments
handleThe MQTT client handle returned by mqtt_create.

General

mqtt_disconnect disconnects the client from the broker.

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

Return Values

MQTT_SUCCESS or MQTT_FAIL

Parameterization

Standard parameterization is not available for this function.

Example

This example shows how to create a connection handle, connect, and disconnect.

/* Declare MQTT client handle variable */

MQTT client;


/* Create client object and assign its handle to a variable */

client = mqtt_create();


/* Connect MQTT client to a broker at test.broker.com using TCP port number 1883 and insecure channel */

mqtt_connect(client, "tcp://test.broker.com:1883");


/*

..... Script logic .....

*/


/* Disconnect MQTT client from the broker */

mqtt_disconnect(client);