Skip to content

Instantly share code, notes, and snippets.

@reubenmiller
Created January 16, 2025 09:23
Show Gist options
  • Save reubenmiller/82b0224b1dc23015262e0cf2d6a089ed to your computer and use it in GitHub Desktop.
Save reubenmiller/82b0224b1dc23015262e0cf2d6a089ed to your computer and use it in GitHub Desktop.
Setting a custom MQTT keep-alive interval using thin-edge.io and mosquitto

Set custom MQTT keep-alive value

Warning: If you run tedge reconnect c8y or tedge connect c8y, you will need to re-edit the c8y-bridge.conf file again (as it is auto generated). thin-edge.io will be added support to configure this value, but it hasn't been implemented yet, see issues/3153.

  1. Stop all thin-edge.io related services

    tedge disconnect c8y
    systemctl stop tedge-agent
  2. Update settings (to minimize data traffic)

    tedge config set c8y.availability.interval 360m

    Alternatively you could turn off the availability monitoring (though you won't get the nice green-icon in Cumulocity)

    tedge config set c8y.availability.enable false
  3. Create the device certificate if you haven't already done so

    tedge cert create --device-id "mydevice001"
  4. Configure the test tenant and upload the device's certificate

    tedge config set c8y.url "example.com"
    tedge cert upload c8y
    
  5. Connect thin-edge.io (though we'll have to manually edit the bridge config afterwards)

    tedge connect c8y
    
  6. Edit the generated c8y-bridge.conf file and add a manual MQTT keep-alive interval

    Open the following file in an editor:

    /etc/tedge/mosquitto-conf/c8y-bridge.conf
    

    Then append the following value under the ### Bridge section:

    keepalive_interval 3540

    Save the file.

  7. Restart mosquitto

    systemctl restart mosquitto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment