I use the mosquitto mqtt broker and have a question about its message id (mid) values as follows.
I send a message to test channel that has a mid of "1234", but the PUBACK mid is printed as another value
I want to print mid "1234"
What do I need to modify in the mosquitto source?
1435417408: Received PUBLISH from adventures (d0, q1, r0, m1234, 'test', ... (5 bytes))
1435417408: Sending PUBLISH to myclientid_49 (d0, q1, r0, m3, 'test', ... (5 bytes))
1435417408: Sending PUBLISH to myclientid_20 (d0, q1, r0, m2, 'test', ... (5 bytes))
1435417408: Sending PUBACK to adventures (Mid: 1234)
1435417408: Received DISCONNECT from adventures
1435417409: Received PUBACK from myclientid_49 (Mid: 3)
1435417409: Received PUBACK from myclientid_20 (Mid: 2)
Let me just go through your broker logs for you.
This line is your published message received from the
adventures
client. You can seem1234
which is saying that the message id is 1234, like you said.These two lines show the message being sent to two clients that are subscribed to the
test
topic. They have message id3
and2
respectively. Note that message ids are handled separately for different clients and message directions.This is the broker sending the PUBACK back to the original client. You'll see again that the message id is 1234.
This is the disconnect message from the original client.
And this is the subscribing clients sending a PUBACK back to the broker, repeating the mid
3
and2
from above.In conclusion, I think it all makes sense.