wolfSSL / wolfMQTT

wolfMQTT is a small, fast, portable MQTT client implementation, including support for TLS 1.3.
https://www.wolfssl.com
GNU General Public License v2.0
526 stars 156 forks source link

Infinite loop for certain buffer sizes #143

Closed mh-ba-dg closed 3 years ago

mh-ba-dg commented 4 years ago

For some constellations of buffer size and payload size, the MQTT client seems not to send all the data. This leads to infinite loops if QoS1 is used, since the client thinks it has sent all the data, but the server is not sending the ACK. If QoS0 is set, the MQTT Client thinks it has sent the data, but the server is running into a timeout and it seems it did not reveive all data.

Example: TX-Buffer size: 512 The buf_len of MqttSocket_WriteDo() is set to 512. MqttSocket_WriteDo() is called only once, but a few bytes (34 Bytes) are still missing. The state machine is not sending anymore, but is waiting for the Server ACK (since QoS is 1)

This might be related to #142

Environment: Microchip Harmony v2.6 OS: FreeRTOS Defines:

define WOLFSSL_BASE64_ENCODE

define WOLFMQTT_CUSTOM_MALLOC

define WOLFMQTT_MALLOC(s) pvPortMalloc((s))

define WOLFMQTT_FREE(p) vPortFree((p))

define ENABLE_MQTT_TLS

define WOLFMQTT_NONBLOCK

define MICROCHIP_MPLAB_HARMONY

define MICROCHIP_TCPIP

define MICROCHIP_PIC32

define MICROCHIP_PIC32_RNG

embhorn commented 4 years ago

Hi @Daniel-Gruber

Again here, could you please attach a snippet showing the wolfMQTT API used to reproduce this error?

Thanks, Eric Blankenhorn wolfSSL Support

mh-ba-dg commented 4 years ago

Same snippet as in #142 I did some more testing and could reproduce the "hangup" when the size of the data to send (topic name + payload [+ some control bytes?]) is near the buffer size NUI16_IO_BUFFER_SIZE_TX .

embhorn commented 4 years ago

I believe this was fixed in #164

embhorn commented 3 years ago

This was fixed by #164. Please feel free to reopen if there are other comments.