Share this page

# mqtt_disconnect

Disconnects the MQTT client from the server.

## C Language

int mqtt_disconnect( MQTT handle);

MQTT Vuser Functions

## Arguments

Name | Comments
--- | ---
handle | The MQTT client handle returned by mqtt_create.

## General Information

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);`

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: