MQTT API Reference
MQTT 3.1.1 client library

Closes an MQTT connection and frees resources.

uint32_t flags );

This function closes an MQTT connection and should only be called once the MQTT connection is no longer needed. Its exact behavior depends on the flags parameter.

Normally, flags should be 0. This gracefully shuts down an MQTT connection by sending an MQTT DISCONNECT packet. Any network close function provided when the connection was established will also be called. Note that because the MQTT server will not acknowledge a DISCONNECT packet, the client has no way of knowing if the server received the DISCONNECT packet. In the case where the DISCONNECT packet is lost in transport, any Last Will and Testament (LWT) message established with the connection may be published. However, if the DISCONNECT reaches the MQTT server, the LWT message will be discarded and not published.

Should the underlying network connection become unusable, this function should be called with flags set to IOT_MQTT_FLAG_CLEANUP_ONLY. In this case, no DISCONNECT packet will be sent, though the network close function will still be called. This function will only free the resources used by the MQTT connection; it still must be called even if the network is offline to avoid leaking resources.

Once this function is called, its parameter mqttConnection should no longer be used.

[in]mqttConnectionThe MQTT connection to close and clean up.
[in]flagsFlags which modify the behavior of this function. See MQTT Function Flags.
void IotMqtt_Disconnect(IotMqttConnection_t mqttConnection, uint32_t flags)
Closes an MQTT connection and frees resources.
Definition: iot_mqtt_api.c:1327
struct _mqttConnection * IotMqttConnection_t
Opaque handle of an MQTT connection.
Definition: iot_mqtt_types.h:66