Search code examples
sonos

Sonos: Lifetime of event subscriptions


For our application we're interested in different types of events, like e.g. playback events, but also group events.

The question that pops up is, how the subscriptions have to be managed. Do they have a lifetime? It makes sense to me that I subscribe to playback events and eventually unsubscribe from them then when the user closed the player in our app.

But what happens if we never actively unsubscribe?

And how about group change events that are not directly connected to a user interacting with our app.

Can I subscribe once for group changes and from then on receive events for weeks and months?


Solution

  • We added more information about event subscriptions to the Sonos developer portal. Subscriptions live for a maximum of three days. If a target player shuts down and does not connect back within the next 30 seconds, it clears target subscriptions.

    If there are any group changes and you're subscribed to the groups namespace, you'll receive a global event indicating group modifications when Sonos cleans up a subscription. Your client must also resubscribe based on any response or event indicating that a group has moved or is gone.

    Subscriptions to the groups namespace get renewed if there are changes to the group. If there are other players in the household, they will immediately claim the subscription and it will be renewed for another three days.

    See Subscription lifetime in the Subscriptions documentation for details.