Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override Liveness timeout on shutdown #771

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

agners
Copy link
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
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.

matter_server/server/sdk.py Outdated Show resolved Hide resolved
@agners agners merged commit 08b1335 into main Jun 25, 2024
4 checks passed
@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