-
-
Notifications
You must be signed in to change notification settings - Fork 629
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
Avahi/DBus: Shutdown of avahi stays undetected and leads to UnhandledPromiseRejection on shutdown. #923
Comments
CC: @adriancable, @oznu |
Hi @Supereg - I would like to re-open this and provide a suggested solution, please. I actually think this is quite important. If avahi crashes for any reason, then it will be restarted by systemd but HAP-NodeJS will not know, and so cannot re-advertise - so from the user's perspective the service will just disappear. The solution is something like this in the constructor for AvahiAdvertiser:
The states are: 0: collision When Avahi starts up, it transitions to state 1 then state 2. So catching StateChanged to 2 will happen whenever Avahi is (re)started and is the correct signal to (re)advertise. |
@Supereg - thanks. Are you OK to add this code snippet to a beta and try it out? (I'm on the road for the next few days, so won't be able to make a PR ...) |
0.10.0 beta is frozen as we prepare for the release. Don't really want to push last minute changes. But will include it in the oncoming beta cycle. |
@Supereg - perfect! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Where do you got the state id mapping from, looking at https://github.com/lathiat/avahi/blob/fd482a74625b8db8547b8cfca3ee3d3c6c721423/avahi-common/defs.h#L220-L227 I would have driven a different mapping. Namely: See also https://github.com/lathiat/avahi/blob/fd482a74625b8db8547b8cfca3ee3d3c6c721423/avahi-daemon/dbus-protocol.c#L1211-L1238 where the |
Addressing issue with #970, review and verification pending. |
This issue is now resolved in HAP-NodeJS version |
Analysis
The current
avahi
advertiser implementation cannot detect if the avahi-deamon is rebooted or stopped. The service advertisement will be removed and will stay removed even if avahi starts again.Additionally, somewhere in the code is a
UnhandledPromiseRejection
triggered when HAP-NodeJS shuts down. Presumably this has to do with the advertiser trying to clean up its records, but failing to do so(?).I haven't tested what happens if a txt record update is triggered while avahi is stoped or when avahi as restarted.
Expected Behavior
Ideally, we could detect a shutdown of avahi and also be notified once it is up and running again, such that we can readvertise our service records.
I think, as soon as we detect that there is a running avahi instance, it is fine to assume it will be started at some point (e.g. might just be a restart).
Steps To Reproduce
Discovery
AVAHI
advertiserLogs
Configuration
-
Environment
Process Supervisor
not applicable
Additional Context
The
Received MESSAGE ...
log output is custom made, and prints anything arriving on thebus.connection.on("message")
event.The text was updated successfully, but these errors were encountered: