Add comms heartbeat to detect lack of message flow - #8450
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8450 +/- ##
==========================================
- Coverage 76.77% 76.64% -0.14%
==========================================
Files 460 460
Lines 24703 24766 +63
Branches 6573 6587 +14
==========================================
+ Hits 18966 18982 +16
- Misses 5737 5784 +47
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Just double checking, because each instance (in the case of FFC where we have 2) has it's own |
hardillb
left a comment
There was a problem hiding this comment.
Approved with the comments about if this is a shared subscription problem this won't catch it from our chat this morning.
Closes #8362
This adds a heartbeat to the CommsClient MQTT connection.
ff/v1/platform/${this.platformId}/heartbeatevery 15 seconds with a payload of the current time in ms.No comms heartbeat received for ${delta} msNo comms heartbeat received for ${delta} ms - reconnectingFor the issue we're trying to handle, messages appear to stop flowing after a client reconnect. The underlying mqtt client handles resubscribing - the theory here is something goes wrong with those subscriptions.
We cannot simply call
client.reconnectin case it is the internal state of the local client that has gone wrong. Instead we disconnect the existing client and reinitialise a new one. Some care has gone into this PR to ensure the old client is properly cleaned up and doesn't interfere with the new one.One key assumptions about the issue we're trying to fix here: That all subscriptions are similarly impacted - so adding one more here works as a detection of a problem elsewhere.
Given we cannot reproduce the issue at will, there is definitely some speculation about whether this fix will help detect it.
The most notable symptom is the Device Status checkin messages not getting through. They are on a shared subscription. If the underlying issue is broker-side related to the shared sub, then this new non-shared subscription isn't going to necessarily spot it.
An alternative would be to send a heartbeat on the device checkin topic - with placeholder team/device ids that can be passed through the ACL check. Going to think about that separately - but we can get this watchdog in place first.