-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Hi, thanks for such a handy tool.
We are using the library to publish some MQTT messages. Some of them are QOS 0, some are QOS 2.
We had no issue with QOS 0 simply by following the example in the main README. But for QOS 2 we struggled to make it work until we noticed that we needed to execute "loop" in order for the whole messages of the protocol are processed, not just the direct publication.
So our code ended being something like this:
$this->mqttClient->publish($mqttInfo->getTopic(), $message, $qualityOfService);
if (MqttClient::QOS_EXACTLY_ONCE === $qualityOfService) {
$this->mqttClient->loop(true, true, $this->maxBrokerWaitTimeInSeconds);
}In our tests we saw that for QOS 1 we didn't need the "loop" call, and that makes sense as the broker will just receive the message and sent it to subscribers even if we don't process the "PUBACK" message that it is sending us back.
But I suspect that not doing so in fact avoids MqttClient from ensuring that the message was really delivered to the Broker "at least once" and in fact a QOS 1 message will just behave as QOS 0, just a fire and forget. Am I correct on this ?
In the other hand I guess that as the second parameter of our "loop" call ensures leaving the method as soon as there are no messages pending in the conversation, wouldn't it be advisable to just always call loop even for QOS 0 messages ? That's something that we can test easily so we will just check by ourselves.
The point is that I didn't find any clarification about those points in the main README.md which, AFAIK, is the only documentation for the library.
I wouldn't mind doing the modification of the README myself in a PR once those concerns are clarified but I guess just clarifying it directly in the README will be much practical.
Once more, thanks for such a handy tool.