Can not receive messages bigger than 127 characters
Closed this issue · 5 comments
Hi,
for some reason i am not able to receive messages that are longer than 127 characters.
I subscribed to a topic and i receive the message when it´s published to the broker only if the length of the payload is shorter than 127 bytes.
Here is the debug output:
libmqtt: Connecting to: tls://broadcast.viewneo.com:9443
libmqtt: Connected to MQTT
libmqtt: Package received, but it doesn't match subscriptions
It seems like something is wrong in the processMessage method?
Is it possible that this library does Not Check the continuation Bit of Byte 2 in the mqtt Header?
I can now confirm, that the issue is libmqtt does not parse the variable length bytes correctly.
I implemented a hotfix to allow messages bigger than 127 bytes in my fork here:
https://github.com/adversign-coders/libMQTT/blob/14b08d035c12a0e5c3448b98817a530e3c2cb8a1/src/Client.php#L351
It´s just a dirty hack for my usecase to work.
A real fix should allow up to four bytes for the lenght in the fixed size mqtt-header
Hi, thank you for the bug report. If you happen to have enough time, would you be able to create a test that fails to this issue? It would be easier to verify that the bug is really fixed and that it doesn't creep back in later on.
Hi,
i dont know if i find the time to create an automated test.
But you could do the following:
- Connect to some broker
- Subscribe to some topic for example: /foo/bar
- Publish the following message to /foo/bar
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You will see that the message will not be correctly parsed by libMqtt.
If you setVerbosity to 2 in libmqtt you will see the output mentioned in my first post.
Regards
André
Hi, problem is now fixed in version 1.0.3