eclipse / paho.mqtt.javascript

paho.mqtt.javascript
Other
1.14k stars 468 forks source link

How can I know my message is sent successfully? #161

Closed toBeGeekNo1 closed 5 years ago

toBeGeekNo1 commented 6 years ago

hello, How can I know my message is successfully to sent the other? Is there have some info feedback? thanks

PeterCAN commented 6 years ago

Its not in the online documentation but have a look at the onMessageDelivered callback for the MQTTClient. In javascript at least it can be initialized like this...

myClient.onMessageDelivered = onMyMessageDelivered;

function onMyMessageDelivered()
{
    console.log("Your message was delivered");
}

If your send() is successful then the callback should be invoked.