MQTT exception

I am getting an Exception from the MQTT code and not from any of my calls.


    #### Exception System.Exception - 0x00000000 (182) ####
    #### Message: Unknown packet type.
    #### GHIElectronics.TinyCLR.Networking.Mqtt.Mqtt::ReceiveThread [IP: 00ef] ####
    #### Exception System.IndexOutOfRangeException - 0xa9000000 (186) ####
    #### Message: 
    #### GHIElectronics.TinyCLR.Networking.Mqtt.Mqtt::DecodePacketTypePublish [IP: 0025] ####
    #### GHIElectronics.TinyCLR.Networking.Mqtt.Mqtt::ReceiveThread [IP: 0085] ####
    #### Exception System.Exception - 0x00000000 (182) ####
    #### Message: Unknown packet type.
    #### GHIElectronics.TinyCLR.Networking.Mqtt.Mqtt::ReceiveThread [IP: 00ef] ####

I then have to reconnect MQTT and this repeats over and over.

Bit of digging by debugging the MQTT source. It is in the ReceveThread() and the packetType = 0

controlHeaderByte[0] = 2

I need to dig into MQTT to figure out what is going on here.

Check the type and flags, it would appear to be a future feature that my MQTT server is sending out. This was the result of a Google Search.

In MQTT, a packet type of 0 with flags set to 2 indicates a RESERVED control packet. This means that the packet is reserved for future use and should not be sent or received by standard MQTT clients or brokers

I found that I was calling Connect twice and once I removed the second Connect, everything is all good now.

2 Likes

I like this from our users.