[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #59313] Possible faulty behavoir in mqtt_close() funct
From: |
Ondrej Lufinka |
Subject: |
[lwip-devel] [bug #59313] Possible faulty behavoir in mqtt_close() function |
Date: |
Wed, 21 Oct 2020 06:52:39 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36 |
URL:
<https://savannah.nongnu.org/bugs/?59313>
Summary: Possible faulty behavoir in mqtt_close() function
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: ondrej_lufinka
Submitted on: Wed 21 Oct 2020 10:52:37 AM UTC
Category: Platform ports
Severity: 3 - Normal
Item Group: Faulty Behaviour
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
lwIP version: git head
_______________________________________________________
Details:
Hi,
I use LwIP on STM32 MCU. I have a working combination of LwIP + MbedTLS +
MQTT. I found a possible faulty behavior in the function:
static void mqtt_close(mqtt_client_t *client, mqtt_connection_status_t
reason)
According to the MQTT standard, a client should send the DISCONNECT (ID = 14)
packet before closing the connection. This function terminates the connection
directly without sending this packet. In my case, I connect to the Amazon AWS
service, and this behavior led to this error:
1. I set Last Will Testament (LWT) before I call mqtt_connect()
2. I open the connection using mqtt_connect()
3. When the connection is lost (e.g. I unplug the ethernet cable from my
device) - LWT is correctly published to AWS
4. But when I close the connection from code (calling mqtt_disconnect(), LWT
should not be published
- according to the MQTT specs
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718090
section 3.14.4
- this is caused because of the missing DISCONNECT packet
5. When I added this code to the begging of the mqtt_close() function, it
works OK:
/* If we have memory -> send disconnect packet */
if (mqtt_output_check_space(&client->output, 0) != 0) {
/* Append fixed header for disconnect packet */
mqtt_output_append_fixed_header(&client->output,
MQTT_MSG_TYPE_DISCONNECT, 0, 0, 0, 0);
/* Send it */
mqtt_output_send(&client->output, client->conn);
}
Can you please verify this behavior and possible solution?
Thank you very much.
Ondrej
_______________________________________________________
Reply to this item at:
<https://savannah.nongnu.org/bugs/?59313>
_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-devel] [bug #59313] Possible faulty behavoir in mqtt_close() function,
Ondrej Lufinka <=