Skip to content
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

Client PUB completion (PUBACK, PUBREC/PUBCOMP) should be performed after the application callback. #2884

Open
CIPop opened this issue Aug 26, 2023 · 0 comments

Comments

@CIPop
Copy link

CIPop commented Aug 26, 2023

The current client implementation will send the PUBACK (likely the same for PUBREC/COMP) before calling the application callback. This can result in messages being lost if the application crashes during the callback.

According to the V3/V5 specs Section 4.3, I believe the intent of the protocol is for the ACK/COMP messages to indicate that the application takes ownership of the message, and not the protocol library.

I propose moving the message acknowledgment after the callback for QoS 1 and 2.


Details

Currently, send__puback is called before the on_message callback:

rc = send__puback(mosq, mid, 0, NULL);

mosq->on_message(mosq, mosq->userdata, &message->msg);

If the ordering is reversed (on_message before send__puback), even if the application crashes in the callback the message isn't lost and will be sent again by the broker after the application recovers (reconnects).

Version: Mosquitto Client (master branch pulled around tag 2.0.16, built from sources).

Related: #118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant