HAP-NodeJS
HAP-NodeJS copied to clipboard
Register listener on the dbus interface to detect Avahi deamon restarts
:recycle: Current situation
As of now we don't detect restarts of Avahi Deamon and therefore remain without an advertising in this situation as explained in #923.
:bulb: Proposed solution
This PR fixes this by subscribing on the dbus StateChanged listener to detect avahi deamon restarts.
:gear: Release Notes
- Properly recreate advertisements on restarts of avahi when using the avahi/dbus based advertiser.
:heavy_plus_sign: Additional Information
Testing
--
Reviewer Nudging
--
@adriancable I'm currently unable to test this on a live machine. Could you verify, that this works as expected?
Pull Request Test Coverage Report for Build 3358922347
- 10 of 28 (35.71%) changed or added relevant lines in 1 file are covered.
- 1 unchanged line in 1 file lost coverage.
- Overall coverage decreased (-0.07%) to 51.913%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| src/lib/Advertiser.ts | 10 | 28 | 35.71% |
| <!-- | Total: | 10 | 28 |
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| src/lib/Advertiser.ts | 1 | 41.61% |
| <!-- | Total: | 1 |
| Totals | |
|---|---|
| Change from base Build 3358848225: | -0.07% |
| Covered Lines: | 5820 |
| Relevant Lines: | 10247 |
π - Coveralls
Hi @Supereg - I'm on vacation until the end of the month and don't have access to a Linux machine to test. I'll happily have a look at the start of October if you can't find anyone else to test before that. Sorry!
Well, Iβm for a half a year in South Korea π so letβs see, maybe I can start up one of my machines at home :) otherwise it will be October π
Have verified functionality (have restarted the daemon twice in the below log output). The re advertisement is also pretty fast:
DEBUG=HAP-NodeJS:Advertiser node dist/BridgedCore.js
HAP-NodeJS:Advertiser Initializing HAP-NodeJS v0.10.4 ... +0ms
HAP-NodeJS fix/avahi-server-state-handling starting...
HAP-NodeJS:Advertiser Detected Avahi over DBus interface running version 'avahi 0.7'. +0ms
HAP-NodeJS:Advertiser Preparing Advertiser for 'Node Bridge 5BA5' using Avahi backend! +1ms
HAP-NodeJS:Advertiser Starting to advertise 'Node Bridge 5BA5' using Avahi backend! +0ms
HAP-NodeJS:Advertiser Found Avahi daemon to have restarted! +21s
HAP-NodeJS:Advertiser Starting to advertise 'Node Bridge 5BA5' using Avahi backend! +0ms
HAP-NodeJS:Advertiser Found Avahi daemon to have restarted! +15s
HAP-NodeJS:Advertiser Starting to advertise 'Node Bridge 5BA5' using Avahi backend! +1ms
Calling avahi-browse afterwards yields positive results:
avahi-browse _hap._tcp --resolve
+ enp0s1 IPv6 Node Bridge 5BA5 _hap._tcp local
+ enp0s1 IPv4 Node Bridge 5BA5 _hap._tcp local
+ lo IPv4 Node Bridge 5BA5 _hap._tcp local
= enp0s1 IPv6 Node Bridge 5BA5 _hap._tcp local
hostname = [primary.local]
address = [fdfa:e7fa:e3cd:3065:5054:ff:febe:4642]
port = [51826]
txt = ["sh=73Llyg==" "ci=2" "sf=1" "s#=1" "pv=1.1" "md=Default-Model" "id=CC:22:3D:E3:CE:F6" "ff=0" "c#=3"]
= enp0s1 IPv4 Node Bridge 5BA5 _hap._tcp local
hostname = [primary.local]
address = [192.168.64.2]
port = [51826]
txt = ["sh=73Llyg==" "ci=2" "sf=1" "s#=1" "pv=1.1" "md=Default-Model" "id=CC:22:3D:E3:CE:F6" "ff=0" "c#=3"]
= lo IPv4 Node Bridge 5BA5 _hap._tcp local
hostname = [primary.local]
address = [127.0.0.1]
port = [51826]
txt = ["sh=73Llyg==" "ci=2" "sf=1" "s#=1" "pv=1.1" "md=Default-Model" "id=CC:22:3D:E3:CE:F6" "ff=0" "c#=3"]