Skip to content

umqtt subscribe to topic with 23 bytes fails #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
DDDanny opened this issue May 31, 2018 · 4 comments
Open

umqtt subscribe to topic with 23 bytes fails #284

DDDanny opened this issue May 31, 2018 · 4 comments

Comments

@DDDanny
Copy link

DDDanny commented May 31, 2018

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

struct.pack_into("!BH", pkt, 1, 2 + 2 + len(topic) + 1, self.pid)
as this is hitting the 128...

@dpgeorge
Copy link
Member

dpgeorge commented Jun 1, 2018

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.

SpotlightKid added a commit to SpotlightKid/micropython-lib that referenced this issue Aug 27, 2018
…coding (fixes micropython#284)

* Add `_varlen_encode` method to write variable length encoded
  remaining length bytes to packet buffer and use it consistently.
* Use `int.from_bytes/to_bytes` to de/encode short integers
  and replace `ustruct` usage with it.
* Correctly separate bytes of fixed and variable header in `connect` method.
* Comment out unused import of `ubinascii.hexlify`.

Signed-off-by: Christopher Arndt <[email protected]>
SpotlightKid added a commit to SpotlightKid/micropython-lib that referenced this issue Aug 27, 2018
…coding (fixes micropython#284)

* Add `_varlen_encode` method to write variable length encoded
  remaining length bytes to packet buffer and use it consistently.
* Use `int.from_bytes/to_bytes` to de/encode short integers
  and replace `ustruct` usage with it.
* Correctly separate bytes of fixed and variable header in `connect` method.
* Comment out unused import of `ubinascii.hexlify`.
SpotlightKid added a commit to SpotlightKid/micropython-lib that referenced this issue Aug 27, 2018
…coding (fixes micropython#284)

* Add `_varlen_encode` method to write variable length encoded
  remaining length bytes to packet buffer and use it consistently.
* Use `int.from_bytes/to_bytes` to de/encode short integers
  and replace `ustruct` usage with it.
* Correctly separate bytes of fixed and variable header in `connect` method.
* Comment out unused import of `ubinascii.hexlify`.
@jonnor
Copy link

jonnor commented Aug 25, 2024

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

@projectgus
Copy link
Contributor

projectgus commented Aug 27, 2024

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

@mbuehler1990
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants