I'm using MQTT protocol to control my Esp8266. But I don't know When Esp got my messenger. So Is there any way I can know that?
2 Answers
The short answer is that you don't.
The longer version:
There is no end to end delivery notification in the MQTT protocol. With QOS 1 or 2 you get assured delivery between any one client and the broker or the broker and a client, not between two clients. (QOS levels can be set on both publish and subscribe)
When you publish a message you can not be sure if there are any connected clients that are subscribed to the relevant topic. If the subscribing client was subscribed at QOS 1 or 2 then the message will be queued and delivered when it reconnects.
The only way to know for sure is to have the receiving client publish a response message acknowledging it has received and acted.

- 54,545
- 11
- 67
- 105
-
Hi Hardillb :. I found a document about mqtt. It talk about QoS 1. Send messenger for client have 3 steps. 1:clients store messenger . 2 : publish to server. 3: Server will store messenger. 4: publish to subscribers . 5 : Server delete messenger. 6: Server PUBACK to clients. So i think with this callback , I can read PUBACK to know does subscribers receive a message? Is that true way? – Đại Ngọc Nguyễn Jan 22 '19 at 09:12
-
No, as I said the QOS hand shake is only between 1 client and the broker, not the publishing client and a subscribing client (there can be 0 to many subscribers). The PUBACK only tells you the message has reached the broker no further – hardillb Jan 22 '19 at 09:15
-
I'm sorry , I wrote wrong, My mean is QoS 2 and PUBREC. This [Schematic](https://www.google.com/search?q=Qos+2&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiX49T8ioHgAhXWdXAKHbHiCWcQ_AUIDigB&biw=1855&bih=984#imgrc=wv1wIza-KKCtwM:) is right? If right, I just read PUBREC to know. – Đại Ngọc Nguyễn Jan 22 '19 at 09:37
-
No, my last answer is true for both QOS 1 and QOS 2 – hardillb Jan 22 '19 at 09:38
-
Can T interfere inside of mqtt? I am thinking, of using qos 2 to make sure to send data to subscribers, there must be a callback between subscribers and qos 2. – Đại Ngọc Nguyễn Jan 22 '19 at 10:43
-
No, as I have said multiple times now, there is NO END TO END DELIVERY NOTIFICATION – hardillb Jan 22 '19 at 10:58
you want konw whether your device recive your message? if this, you can set QoS to 1 or 2 make sure your device receive your message
or you want to konw when your device receive your message? if this, seems need your device feedback,when receive a message then send a message with time to you.

- 31
- 4
-
So do I need a topic for confirm that? When subscribers has messenger , them will send messenger to the topic. After that, clients will know. That right? – Đại Ngọc Nguyễn Jan 22 '19 at 09:17
-
yes, in our case, we do it like this, client subscribe : topic/stc/[clientid or machine code] and server subscribe : topic/cts/[clientid or machine code] cts: client to server, stc:server to client, and machinecode is client device id or something can identify it. – linxingyang Jan 23 '19 at 03:04