Hi Toby, > Ok, so I should only be expecting on_publish() for QOS > 0.
Actually you do get on_publish() for QoS==0 as soon as the network bytes are completely sent. There's no guarantee that the broker gets them of course. > 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. That's a tricky one. This is what libmosquitto does when sending messages: QoS 0: Send PUBLISH as soon as possible and once written call on_publish(). QoS 1: Send PUBLISH as soon as possible and once PUBACK has been received, call on_publish(). If PUBACK not received after a timeout, resend PUBLISH. QoS 2: Send PUBLISH as soon as possible, wait for PUBREC. If PUBREC not received after a timeout, resend PUBLISH. On PUBREC received, send PUBREL and wait for PUBCOMP. If PUBCOMP not received after a timeout, resend PUBREL. On PUBCOMP, call on_publish(). For the QoS 1,2 cases it will keep on trying to send the message if it isn't acknowledged. By default the timeout for each phase of the message handshake is 20 seconds but it can be changed. Something that might help your situation would be to have the ability to retry a fixed number of times and then call on_publish() but with an error. With a low message timeout you would at least get a response then, even if it's not much different to just assuming it hasn't sent after a timeout. > I guess that I should return an HTTP failure code after a timeout, but accept > that the MQTT message "might" have been delivered. That sounds not unreasonable. You might also be interested to know that test.mosquitto.org gives mqtt over websockets access now, as shown by the very poor demo at http://test.mosquitto.org/ws.html Cheers, Roger _______________________________________________ Mailing list: https://launchpad.net/~mqtt-users Post to : [email protected] Unsubscribe : https://launchpad.net/~mqtt-users More help : https://help.launchpad.net/ListHelp

