Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    AWSIoTMQTTClient keepalive interval?

    Scheduled Pinned Locked Moved Issues & Bugs
    aws mqttaws iotbandwidthlte-mlte m1
    4 Posts 2 Posters 925 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      reidfo
      last edited by reidfo

      I've just gotten my FiPy to connect to AWS IoT via TLS and MQTT. In monitoring the device it is sending a little over 200 bytes to AWS every 20 seconds. I see Packet sent. (Length: 2) at 20 second intervals. While this might be fine over WiFi it will nearly use up my 1MB LTE Cat M1 data plan after one day just with these keepalive packets. How do I reduce the keepalive interval with the built-in AWSIotMQTTClient? There is no way I can deploy on LTE with this much data being transmitted. This doesn't even include any of my actual MQTT messages! Just the keepalives.

      C 1 Reply Last reply Reply Quote 0
      • C Offline
        cmisztur @reidfo
        last edited by cmisztur

        @reidfo looks like simple.py constructor takes a keepalive

        def __init__(self, client_id, server, port=0, user=None, password=None, keepalive=0,
                         ssl=False, ssl_params={}):
        

        oh I wasn't aware of AWSIotMQTTClient... maybe this:

        https://github.com/pycom/pycom-micropython-sigfox/blob/f517b1df5083ddc158c075852d7f2497480b0d84/esp32/frozen/Common/MQTTLib.py#L43

        R 1 Reply Last reply Reply Quote 0
        • R Offline
          reidfo @cmisztur
          last edited by reidfo

          @cmisztur That does take a parameter, in connect() called keepAliveIntervalSecond, but when I set it it seems to be ignored. Keepalive packets are still being sent every 20 seconds. Following the code, AWSIotMQTTClient.connect() ends up calling MQTTClient._send_connect() and is passed the keepalive parameter, but it does nothing with it.

          C 1 Reply Last reply Reply Quote 0
          • C Offline
            cmisztur @reidfo
            last edited by

            @reidfo Sure looks like it. Change line 294, see if you get a different behavior.

            http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349238

            https://github.com/pycom/pycom-micropython-sigfox/blob/f517b1df5083ddc158c075852d7f2497480b0d84/esp32/frozen/Common/MQTTClient.py#L294

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom