← Back to team overview

mqtt-users team mailing list archive

Re: libmosquitto async publishing

 

On Thu, Jun 07, 2012 at 11:12:39AM +0100, Roger Light wrote:

[snip]

> If the message is not sent immediately, the network writes will occur
> on a later call to mosquitto_loop() which will return the same errors
> in the case of a failure. They're more on the lines of general network
> errors than publish failures though. on_publish is very much a "your
> message has been sent successfully" report, particularly for the
> higher QoS levels where it indicates that the handshake with the
> broker has completed successfully, not just that the message has been
> written to the network.

Ok, so I should only be expecting on_publish() for QOS > 0.  But, (for QOS >
0) how do I detect failure to publish with libmosquitto?

I assume that the broker might fail to ACK my message.

If my application code times out on not receiving on_publish() then it might
think that the message was not published when in fact, it got delayed then
published later.


To give some background, I'm building an HTTP to MQTT bridge. When an HTTP
request to publish comes in (with QOS > 0), the HTTP request's socket is
blocked until the MQTT transaction completes. I can detect success with
on_publish() then return HTTP 200 to the client. I'm trying to work out what to
do in the case where on_publish() never calls back.

I guess that I should return an HTTP failure code after a timeout, but accept
that the MQTT message "might" have been delivered.

--



Follow ups

References