-
Notifications
You must be signed in to change notification settings - Fork 15
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
Check confirmation - QoS 1 #8
Comments
You can't really check that specifically, but the client will attempt to resend the message in case no PUBACK is received based on the configured timeout in the However, for QoS > 0 you need to run $client->loop(allowSleep: true, exitWhenQueuesEmpty: true, queueWaitLimit: 10); This will exit the loop immediately when PUBACK is received, but it will retry up to 10 seconds. If the message could not be delivered within 10 seconds, it will exit anyway. See A more complete example would be: $connectionSettings = (new ConnectionSettings())
->setResendTimeout(3); // Resend messages every 3 seconds
$client = new MqttClient($server, $port, $clientId);
$client->connect($connectionSettings);
$client->publish('foo/bar/baz', 'Hello world!', MqttClient::QOS_AT_LEAST_ONCE);
$client->loop(allowSleep: true, exitWhenQueuesEmpty: true, queueWaitLimit: 10); This will attempt to resend the message every 3 seconds for up to 10 seconds (i.e. 4 attempts). You can also omit the |
Thanks for reply. Right, what I have to do is to display a message saying: Is there a way to check if PUBACK was confirmed or at least that an error has ocurred? just so I can inject my logic into there? I am currently using: |
There is no way to check the transmission result or status of individual messages. So the only way you can know for sure that a queued message (or all queued messages) was successfully sent to the broker is by looping until the loop exits by itself: $client->loop(allowSleep: true); However, you should note that this only tells you whether the message was sent to the broker successfully, but not if any of the subscribers actually received the message. If you, for example, want to push a command to an individual client indirectly via an MQTT broker, the client should acknowledge the command on a separate topic. It's called the RPC pattern. |
I am publishing a message with:
How do I check if the message was confirmed and PUBACK was sent back?
The text was updated successfully, but these errors were encountered: