Edge device MQTT connection drops due to security policy token expiry, impacting real-time telemetry ingestion

Our edge devices are experiencing intermittent MQTT connection drops every 24 hours, resulting in telemetry data loss during the reconnection window. Investigation shows this aligns with our security policy token expiry settings.

Current token configuration:


token.lifetime=86400
token.renewBefore=3600
MQTT.sessionPersist=false

The issue is that token renewal configuration doesn’t seem to trigger before expiry, causing devices to disconnect. We’re losing 2-5 minutes of telemetry data during each reconnection cycle. The device SDK auto-refresh mechanism isn’t working as expected - devices wait until connection failure before attempting token renewal. MQTT session persistence is disabled which compounds the problem. Any insights on proper token renewal setup?

I had this exact issue. The problem is MQTT.sessionPersist=false. When tokens expire and devices reconnect, they’re establishing completely new sessions instead of resuming existing ones. This causes message loss during the reconnection window. Enable session persistence and set cleanSession=false in your MQTT client configuration. Also, your SDK version might not support automatic token refresh - check if you’re on sapiot-24.2 or later.

Also consider the network latency factor. If your edge devices have unreliable connectivity, the 1-hour renewBefore window might not be enough. We use 7200 seconds (2 hours) for edge deployments with intermittent connectivity. And definitely enable MQTT session persistence - there’s no good reason to have it disabled in production.

We’re on sapiot-24.1 which might explain the auto-refresh issue. Upgrading to 24.2 isn’t straightforward in our environment. Is there a workaround for implementing token refresh in 24.1, or should we adjust the token lifetime to avoid expiry altogether?