Skip to content

Override Liveness timeout on shutdown#771

Merged
agners merged 2 commits intomainfrom
shutdown-subscription-logic-attempt-with-livenss-timeout
Jun 25, 2024
Merged

Override Liveness timeout on shutdown#771
agners merged 2 commits intomainfrom
shutdown-subscription-logic-attempt-with-livenss-timeout

Conversation

@agners
Copy link
Copy Markdown
Collaborator

@agners agners commented Jun 24, 2024

Override the liveness timeout when a node announces a shutdown. This causes the subscription logic to notice that the device went offline much quicker, which is especially nice for battery operated devices which have a high liveness timeout.

We use 5s as timeout to make sure the device really completed shutdown, and that the first subscription resumption triggered by this actually fails. We can restore the timeout to default immediately after, since the SDK is in subscription resumption mode now.

Another alternative would be to shutdown the subscription (mark the device as offline). This has the disadvantage that the controller needs to recreate the subscription from scratch when it comes back, which causes unnecessary traffic.

If the node stays offline for longer than 30s, we'll still trigger the offline logic which will shutdown the subscription entirely.

Override the liveness timeout when a node announces a shutdown. This
causes the subscription logic to notice that the device went offline
much quicker, which is especially nice for battery operated devices
which have a high liveness timeout.

We use 5s as timeout to make sure the device really completed shutdown,
and that the first subscription resumption triggered by this actually
fails. We can restore the timeout to default immediately after, since
the SDK is in subscription resumption mode now.

Another alternative would be to shutdown the subscription (mark the
device as offline). This has the disadvantage that the device needs
to recreate the subscription from scratch when it comes back, which
causes unnecessary traffic.

If the node stays offline for longer than 30s, we'll still trigger
the offline logic which will shutdown the subscription entirely.

This is mainly useful for updates, where the node goes offline
gracefully (announced with the shutdown event) and comes back soon
after.
@agners agners added the maintenance Code (quality) improvement or small enhancement which not a new feature label Jun 24, 2024
Copy link
Copy Markdown
Contributor

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the SDK details but Python wise it looks good.

Comment thread matter_server/server/sdk.py Outdated
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
@agners agners merged commit 08b1335 into main Jun 25, 2024
@agners agners deleted the shutdown-subscription-logic-attempt-with-livenss-timeout branch June 25, 2024 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Code (quality) improvement or small enhancement which not a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants