[quote=“lolodomo”]My hypothesis is that the proxy does not erase its table even when reloading lua and so the proxy tries to redirect events to a Sonos device that does no more exist.
If I am right, the errors should stop as soon as the subscription will expire (max 1 hour).
Would it be possible and a good idea that you first check that the device still exists before redirecting something to it ?[/quote]
I agonized about this problem when I first noticed it months ago. Let me explain the thought process that led to me leaving it the way it is as the lesser of two evils. Perhaps you can talk me around, if you can suggest a way to overcome the problems.
Luup restarts are sudden. There’s no time for a client UPnP plugin (like a Sonos or WeMo plugin) to cancel its own subscriptions. The plugins are just reset and they shortly run their startup code again. So the only way for old subscriptions to be cancelled is for some code to do it as part of the Luup restart. Probably in the UPnP proxy plugin device itself, since that’s the only one that is guaranteed to exist. Especially if you’ve just deleted a device.
During a Luup restart, I can’t control the order in which the devices run their startup code. If the UPnP proxy plugin tells the proxy process to flush its memory of past subscriptions then there’s a risk that it’ll wipe out a subscription made seconds ago in parallel by the Sonos plugin that just started up.
I judged that a few rogue notifications, for only an hour, which will be ignored anyway, was safer than risking a race condition that (only sometimes) killed valid notifications.
If the proxy process could get back a “no such device” or “no such action” message as an error, then it could remove the notification from its table. But the LuaUPnP call_action request always returns 200 OK. So that won’t work.
Another possibility that I just thought of tonight is for each notification to be accompanied with an epoch, a number that can identify a particular run of LuaUPnP. Restart Luup, and you get a new epoch. Then, as the UPnP proxy plugin runs its startup Lua, it could tell the background process what the new epoch is, and the background process could delete any notification belonging to a different epoch. The “loadtime” attribute in lu_sdata is perfect for this, because it changes only when the Luup engine reloads. Unfortunately it is not exposed to the Lua runtime, and forcing plugins to do an HTTP request to get lu_sdata seems like a lot of trouble just to make a cleaner log.
So there we are. On the one hand, ugly messages in the log. On the other, more complexity for client plugins. What would you do?