-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disconnect message not implemented #97
Comments
Hi @gregjesl Thank you for raising this issue! |
@david-cermak Great, thank you. After looking through the code, it appears the appropriate place to add the functionality would be here: Lines 776 to 782 in 99004f2
My suggestion would be: esp_err_t esp_mqtt_client_stop(esp_mqtt_client_handle_t client)
{
// Notify the broker we are disconnecting
client->mqtt_state.outbound_message = mqtt_msg_disconnect(&client->mqtt_state.mqtt_connection);
if (mqtt_write_data(client) != ESP_OK) {
ESP_LOGE(TAG, "Error disconnecting");
return ESP_FAIL;
}
client->run = false;
xEventGroupWaitBits(client->status_bits, STOPPED_BIT, false, true, portMAX_DELAY);
client->state = MQTT_STATE_UNKNOWN;
return ESP_OK;
} I'd submit a pull request but I never seem to have much luck with Git submodules. |
@gregjesl Thanks for your suggestion! |
@david-cermak I struggled with the rebase so I branched from |
closed per caf5007 |
After reviewing and using the code, it does not appear that the MQTT client ever sends the DISCONNECT packet to the broker. Simply "dropping the line" can lead to undesirable behavior on the broker, especially when the client tries to reconnect.
The text was updated successfully, but these errors were encountered: