• Johan Ström's avatar
    Handle large/chunked/fragmented MQTT messages properly (#2571) · 2d958750
    Johan Ström authored
    * MQTT: handle large/chunked/fragmented messages properly
    
    If a message spans multiple TCP packets it must be buffered before
    delivered to LUA. Prior code did not do this at all, so this "patch"
    really adds proper handling of fragmented MQTT packets.
    This could also occur if multiple small messages was sent in a
    single TCP packet, and the last message did not completely fit in that
    packet.
    
    Introduces a new option to the mqtt.Client constructor:
    max_publish_length which defaults to 1024
    
    Introduces a new 'overflow' callback.
    
    Fixes issue #2308 and proper fix for PR #2544.
    
    * mqtt.md: clarified heap allocation
    
    * mqtt: ensure ack is sent for overflowed publish
    
    If QoS is used we should still acknowledge that we received it, or server might retransmit it later.
    2d958750
mqtt.c 61.7 KB