Closed dethegeek closed 7 years ago
Hi
I discovered when the lib receives a PUBLISH MQTT message with a remaining_length_bytes = 48 an exception is thrown
Exception while listening MQTT messages : #0 .../vendor/sskaje/mqtt/mqtt/Message/Base.php(116): sskaje\mqtt\Message\Header\Base->decode('00\x00\x19/5/agent/c3...', 48, 0) #1 .../vendor/sskaje/mqtt/mqtt/MQTT.php(1318): sskaje\mqtt\Message\Base->decode('00\x00\x19/5/agent/c3...', 48) #2 .../vendor/sskaje/mqtt/mqtt/MQTT.php(793): sskaje\mqtt\MQTT->message_read() #3 .../vendor/sskaje/mqtt/mqtt/MQTT.php(779): sskaje\mqtt\MQTT->handle_incoming() #4 .../vendor/sskaje/mqtt/mqtt/MQTT.php(1135): sskaje\mqtt\MQTT->handle_message() #5 .../inc/mqttclient.class.php(94): sskaje\mqtt\MQTT->loop() #6 .../scripts/mqtt.php(37): PluginStorkmdmMqttclient->subscribe() #7 {main}
Notice the remaining length equals the first byte of the message (PUBLISH). Because the first byte and the second bytes are the same, the strpos reports the position of the first byte instead of the second, and it does not matches $pos.
An example of cli to trigger the exception
mosquitto_pub -t "/a/agent/azertyui/gsdfghj" -m '{"query":"Inventory"}'
Merged, thanks again.
Hi
I discovered when the lib receives a PUBLISH MQTT message with a remaining_length_bytes = 48 an exception is thrown
Notice the remaining length equals the first byte of the message (PUBLISH). Because the first byte and the second bytes are the same, the strpos reports the position of the first byte instead of the second, and it does not matches $pos.