micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

umqtt subscribe to topic with 23 bytes fails

Open DDDanny opened this issue 7 years ago • 4 comments

Hi, I can't subscribe to topic longer than 122 bytes. Publishing works fine! I kindly ask you to verify and hopefully fix it Thanks a lot Danny

OK - working:

#122 bytes
mqtt.subscribe(b"/234567890/234567890/234567890/234567890/234567890/234567890/234567890/234567890/234567890/234567890/234567890/234567890/2") 

but one more character:

#123 bytes
mqtt.subscribe(b"/234567890/234567890/234567890/234567890/234567890/234567890/234567890/234567890/234567890/234567890/234567890/234567890/23") 

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "test.py", line 169, in <module>
  File "umqtt_simple.py", line 154, in subscribe
  File "umqtt_simple.py", line 173, in wait_msg
OSError: -1

this might be related to #163 which also deals with 127 bytes

it might be related to https://github.com/micropython/micropython-lib/blob/f20d89c6aad9443a696561ca2a01f7ef0c8fb302/umqtt.simple/umqtt/simple.py#L148 as this is hitting the 128...

DDDanny avatar May 31 '18 20:05 DDDanny

It looks like the subscribe method needs to handle variable length encoding of the payload size, in the same way that connect and publish do.

dpgeorge avatar Jun 01 '18 02:06 dpgeorge

This appears ot have been fixed in the linked MRs/commits. Proposing to close this issue.

jonnor avatar Aug 25 '24 11:08 jonnor

Looks like the author's PR was closed last year without merging, so I think this may still be an issue.

projectgus avatar Aug 27 '24 02:08 projectgus

I had the same issue and @SpotlightKid fix worked for me. Sad that the PR is not merged

mbuehler1990 avatar Nov 19 '24 17:11 mbuehler1990