-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Question: how to get notified of puback for QoS1 on the client #944
Comments
I guess, you cannot get plain PUBACK messages at all... This is handled internally as far as I know. @chkr1011 This is something you need to answer. |
Thanks, @SeppPenner. My context is I have a client app that sends a set of messages, and then reports that it was able to send them successfully. In QoS 0, success would be if I was able to send, but for QoS 1, I'd consider that success is if it is successfully received, as determined by a PUBACK. Is there an alternative manner in which I can know that the message was indeed received? |
I am using EMQX mqtt broker, In case of EMQX broker, if there is 0 subscriber for a topic then broker drop that particular message which client A has published. In this scenario, Client A may not come to know whether message is received by subscribers or not. You can check if below solution can solve your problem. Client can wait for message delivery confirmation from subscriber in terms of acknowledgement. Client A will publish a message with unique message identifier in payload. When subscriber receives such message, subscriber can publish a simple message along with that identifier on a acknowldgement topic. Client A will subscribe to this topic and can recieve messages. Then client A can updated flags in its system as messaged delivered. |
@kedar-hatkar That was the idea I would have suggested as well as I don't think this is possible natively. |
Thanks, folks. In my case, I don't have control over the subscriber so I won't be able to get the subscriber to send an ack message explicitly. I am only interested in knowing whether the send to the broker succeeded - and I understand that QoS 1 is basically that - when the broker has received the message, it sends a PUBACK, so the client is assured of the 'at least once' success. Earlier, I was using M2MQTTClient, and that did give me a PUBACK. Any way I can get that to happen for MQTTNet? |
hi, have you solve that problem, I have the same problem now. |
Paho.Java have the callback function when msg published success or fail. but not mqttnet. M2mqtt also have callback when meg published success. |
Messages are considered as published when the awaited Task returns and doesn't run into an exception. try
{
var message = new MqttApplicationMessageBuilder()
.WithTopic("MyTopic")
.WithPayload("Hello World")
.WithExactlyOnceQoS()
.WithRetainFlag()
.Build();
await mqttClient.PublishAsync(message, CancellationToken.None);
// If we reach this line, the publish worked.
}
catch (MqttCommunicationException ex)
{
// I'm not sure about the exact name of this exception class...
// There was an error, message maybe wasn't sent (Depending on the exception type / message).
} |
Hi, we can realize this function in MQTTnet.Extensions.ManagedClient. |
When using QoS1 on the client, what is the callback that is invoked for the PUBACK from the server?
Which project is your question related to?
Thanks in advance!
The text was updated successfully, but these errors were encountered: