adafruit / Adafruit_CircuitPython_MiniMQTT

MQTT Client Library for CircuitPython
Other
72 stars 50 forks source link

MMQTTException: invalid message received as response to SUBSCRIBE: 0x31 - v7.3.2 and 7.4.0 #171

Closed cn-schuh closed 12 months ago

cn-schuh commented 12 months ago

Hello,

Recently i figured out an probelm after updateing to minimqtt 7.4.0 (same with 7.3.2). When sending multiple subscribes (as str) the error below occurs. Using a list it is even better, but only when send all topics in a single list. Problem with the list, i am expecting problems when i am using this in my original code (40 subscribes). It seems to be not related on the retain flag. More than 2 subscribes as str or list seems to cause the issue.

Example as list mqtt.subscribe([("test",0),("test1",0)]) mqtt.subscribe([("test2",0),("test3",0)]) or as str: mqtt.subscribe("test",0) mqtt.subscribe("test1",0)

I am using mosquitto 1.5.7 as MQTT Broker.

Error Message: Connected to MQTT Broker! Subscribed to /groups/device with QOS level 0 New message on topic /groups/device: 0 Traceback (most recent call last): File "code.py", line 107, in File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 858, in subscribe MMQTTException: invalid message received as response to SUBSCRIBE: 0x31

Attached a modified code form the example.

To test, the ssid and key has to be added in wifi.radio.connect("", "") in line 21 and the broker in line 77. As mentioned, the first occurancy was with 7.3.2.

I hope i didn't missed any new functions and reported these as error.

code.txt

cn-schuh commented 12 months ago

Looks like a timing issue, to many subscribes at the same time. Reduced to 4 subscribses, interrupt and next 4.

cn-schuh commented 12 months ago

When passing topics by list, it have to be limited to 4 items, break (in my case 0.5), next 4 items and so on.