Skip to content

Commit

Permalink
Gracefully disconnect MQTT (#23)
Browse files Browse the repository at this point in the history
* Gracefully disconnect MQTT

* Add MG_F_SEND_AND_CLOSE flag to disconnect
  • Loading branch information
guywithaview committed Mar 25, 2021
1 parent 2b43e81 commit 5d169b5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mgos_mqtt_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ void mgos_mqtt_conn_disconnect(struct mgos_mqtt_conn *c) {
if (c == NULL) return;
c->reconnect_timeout_ms = -1; // Prevent reconnect.
if (c->nc != NULL) {
c->nc->flags |= MG_F_CLOSE_IMMEDIATELY;
mg_mqtt_disconnect(c->nc);
c->nc->flags |= MG_F_SEND_AND_CLOSE;
}
}

Expand Down

0 comments on commit 5d169b5

Please sign in to comment.