Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Offline buffering in Python3 Paho MQTT client

Lars Noodén <lars.nooden@xxxxxxxxx> writes:

> I am trying to have a Python3-based Paho MQTT client do offline
> buffering during longer intervals when there is no network connectivity.
>  Can someone please point me to the right documentation and/or a code
> snippet showing the right way to do that?  Short intervals work but not
> longer ones.

You say "buffering", but once you talk about offline then this veers
into database sync.  I think it's an important use case.

One question is if buffered MQTT is really the problem statement, or a
solution.  As I see it, sensors measure things (or whatever generates
data) and then this data is conveyed to someplace where it is
stored/used/processed.  People construct a protocol, almost always
undocumented, around sending messages of some particular form with
MQTT.  Sometimes this includes a timestamp.

> I have a test script [2] otherwise working.  It sends data to the MQTT
> broker just fine while there is network connectivity and resumes sending
> once the connectivity is restored after a short period of disconnection.
>  However, the messages which would have been sent during a longer period
> without connectivity seem to disappear completely.  I would have
> expected the client to have kept a queue which gets sent in bulk once
> the connection is re-established.

Data has to be queued someplace, certainly.  I don't really have any
insight into this issue.

Another issue is that for capable platforms, one might well want to
persist messages that can't be delivered in the filesystem, so that
after a restart of the processs the data can be sent, rather than only
surviving in RAM.  This basically acts like mail, or somewhat like xmpp.

On my todo list is to write a M2M jabber client that accepts messages
locally and sends them, and failing an ack, persists them.  My basic
notion is that I use xmpp for notifcations from Home Assistant and I
don't want to lose them.  MQTT is really exactly the same situation, and
the same persistence notion would be nice for notifications over MQTT.

In the case of reporting temperatures once a minute, persistence makes
sense, but to me at least, only if you include timestamps.

Do you think this sort of offline/retransmission schemes need to
preserve ordering?

> PS.  Thank you in advance for not top-posting.

:-)

Attachment: signature.asc
Description: PGP signature


Back to the top