Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] When is the publish callback called?

Hi Mark,

For QoS 0, the on_publish callback is called after a successful
write() of the packet - so it the data has been sent to the OS for
sending. If you're using TLS it's possible that may not mean the
transmission is complete of course.

For QoS 1 and 2, on_publish is called in
_mosquitto_handle_pubackcomp(), which is called when a client receives
a PUBACK or a PUBCOMP, depending on the QoS - i.e. the final stage of
the publish handshake in both cases.



On Thu, Jan 28, 2016 at 2:01 PM, Mark Pilant <lpilant@xxxxxxxxxx> wrote:
> I'm looking to do some publish timing tests, client to broker (and back?);
> now that I have my test program running (thanks Roger).
> Looking at the documentation, it isn't entirely clear when the publish
> callback (or any other callback for that matter) is called; which I would
> assume depends on the QoS level.
> Here is what I would have expected: QoS 0, after the message is sent (not
> necessarily queued to be sent) and QoS 1 and 2, when the broker confirms the
> message has been received. However, this is not what I'm seeing. What I'm
> seeing appears to be after the message is sent (queued?) for QoS 0 and 1. I
> haven't tested QoS 2.
> Is my expectation correct? If not, is there some way (API call, option,
> etc.) to accomplish this?
> Thanks in advance.
> - Mark
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit

Back to the top