I experienced this exact issue three months ago with perception sensors on c8y-1020. The problem isn’t just MQTT configuration - it’s the interaction between edge device reboot handling and shadow state management. Here’s what you need to verify:
First, your subscription order matters critically. On reconnection, subscribe to shadow topics BEFORE publishing any state:
// Subscribe first
client.subscribe("shadow/update/delta", 1);
client.subscribe("shadow/get/accepted", 1);
// Then request current shadow
client.publish("shadow/get", "{}", 1, false);
Second, implement proper reboot handling with a reconnection strategy that accounts for shadow synchronization timing. The key is requesting the current shadow state immediately after subscription and waiting for the response before publishing device state updates.
Third, adjust your MQTT persistent session parameters. While cleanSession=false is correct, you need to tune the session expiry interval. Add this to your configuration:
mqtt.sessionExpiryInterval=3600
mqtt.receiveMaximum=10
The sessionExpiryInterval ensures the broker maintains your session for up to an hour during unexpected reboots. The receiveMaximum limits in-flight messages to prevent queue overflow during reconnection.
Fourth, implement a shadow synchronization verification step in your edge device reboot sequence. After reconnection, your device should:
- Subscribe to shadow/update/delta and shadow/get/accepted topics
- Publish to shadow/get to request current shadow state
- Wait for shadow/get/accepted response (with 5-second timeout)
- Compare received shadow version with local state
- Only then publish device reported state updates
This ensures your device and platform are synchronized before attempting state updates. The 10-15 minute delay you’re seeing is Cumulocity’s built-in shadow reconciliation mechanism detecting the desync and forcing a full resync.
Finally, verify your edge device’s MQTT client library properly implements MQTT 5.0 session management. Some older clients don’t handle session expiry correctly, causing the broker to treat reconnections as new sessions despite cleanSession=false.
Implementing this complete reboot handling workflow eliminated our shadow sync issues entirely. The key insight is that MQTT persistent sessions alone aren’t sufficient - you need explicit shadow state verification as part of your reconnection logic. This addresses all three critical areas: MQTT persistent session configuration, device shadow update topic subscription timing, and proper edge device reboot handling with state reconciliation.