Using MQTT with expensive data plans (infrequent publishing)

38 views
Skip to first unread message

Jimmie

unread,
Mar 19, 2018, 11:25:31 PM3/19/18
to MQTT
Hello,

I am new to MQTT and would appreciate help in answering my question:

Basically, I am using MQTT to connect a cellular device to the MQTT broker.  All the programming examples I have seen use a permanent connection with reconnect if connection is lost.

However, I am using a device on an expensive data plan (with low bandwidth).  I am assuming that a permanent connection will keep sending to the broker Alive messages even if there is no client transmissions? This would make it expensive cost-wise.

So what is the recommendation?  Is it to disconnect then reconnect?  Any code examples?

Thanks in advance.

Andy Stanford-Clark

unread,
Mar 20, 2018, 5:28:49 AM3/20/18
to 'Simon H' via MQTT
As usual, “it depends” ;)

you can back off the keepalive timer (maybe once every 5 minutes?). And the keep alive is only 2 bytes in each direction.

Connecting, particularly with credentials, is quite a lot of bytes.
Subscribing (if your device does that) requires the topics to be written out in full, so can be quite a lot of bytes, also.

So it depends really - how often are you going to be sending data? If it’s (say) once a day, then yes, just connect, publish, disconnect.

If you need to receive a message to the device, whether you need to be always connected depends on how quickly you need to react to that message….
In the one connection per day example, if you are happy to receive your messages at the one time a day you connect, then sending the message QoS 1 or 2 (assured delivery) will make sure the messages are queued for delivery to the device when it connects. (make sure you set cleanSession to false)
If you need to react immediately to a message sent to the device, then you will need to stay connected, so it can be delivered to you as soon as it is published.

I hope that helps?
Andy

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Amr A. Oloufa

unread,
Mar 20, 2018, 7:44:02 AM3/20/18
to mq...@googlegroups.com
Thank you very much Andy, it is very clear now.

Best regards.

To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.

To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to a topic in the Google Groups "MQTT" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mqtt/5xgzQRq7Ys4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mqtt+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages