An API for using MQTT over multiple transports

Dependencies:   FP MQTTPacket

Dependents:   Cellular_HelloMQTT IoTStarterKit GSwifiInterface_HelloMQTT IBMIoTClientEthernetExample ... more

Issue: Network is closed after calling unsubscribe

Version
  • MQTT: 9cff7b6bbd01
  • MQTTPacket: aedcaf7984d5
  • FP: 3c62ba1807ac
Description

I meet an issue that network is closed after calling MQTTClient::unsubscribe. With preliminary check, it was caused by UNSUBACK lost in switch block below:

MQTTClient.h

template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE, int b>
int MQTT::Client<Network, Timer, MAX_MQTT_PACKET_SIZE, b>::cycle(Timer& timer)
{
    // get one piece of work off the wire and one pass through
    int len = 0,
        rc = SUCCESS;

    int packet_type = readPacket(timer);    // read the socket, see what work is due

    switch (packet_type)
    {
        default:
            // no more data to read, unrecoverable. Or read packet fails due to unexpected network error
            rc = packet_type;
            goto exit;
        case 0: // timed out reading packet
            break;
        case CONNACK:
        case PUBACK:
        case SUBACK:
        **UNSUBACK is lost here**
        case UNSUBACK:
            break;
        case PUBLISH:
        {