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

v0.11.0 fails on Synology #993

Closed
ebaauw opened this issue Dec 14, 2022 · 15 comments
Closed

v0.11.0 fails on Synology #993

ebaauw opened this issue Dec 14, 2022 · 15 comments
Labels

Comments

@ebaauw
Copy link
Contributor

ebaauw commented Dec 14, 2022

Analysis

Homebridge v1.6.0, or rather HAP-NodeJS v0.11.0 doesn't work on my Synlogy. I'm getting an error Could not create mDNS advertisement. The HAP-Server won't be discoverable: Error: No such interface found
Haven't changed anything on my config; reverting to Homebridge v1.5.9 / HAP-NodeJS v0.10.4 solves the issue.
Using Avahi as advertiser.
I'm running a DS920+ and a DS918+, both on DSM 7.1.1. Both use link aggregation; the interface name is ovs_bond0. The Homebridge UI does find this interface, and displays the network activity graph.

Expected Behavior

HAP-NodeJS should advertise itself.

Steps To Reproduce

Upgrade Homebridge to v1.6.0 on Synology with avahi as advertiser.

Logs

[12/14/2022, 10:39:20 PM] [HB Supervisor] Restarting Homebridge...
[12/14/2022, 10:39:20 PM] [HB Supervisor] Starting Homebridge with extra flags: -P /volume1/homebridge/node_modules -D --strict-plugin-resolution
[12/14/2022, 10:39:20 PM] [HB Supervisor] Starting Homebridge with custom env: {"DEBUG":"HAP-NodeJS:Advertiser","NODE_OPTIONS":"--trace-warnings"}
[12/14/2022, 10:39:20 PM] [HB Supervisor] Started Homebridge v1.6.0 with PID: 26647
2022-12-14T21:39:21.212Z HAP-NodeJS:Advertiser Initializing HAP-NodeJS v0.11.0 ...
[12/14/2022, 10:39:21 PM] Loaded config.json with 0 accessories and 1 platforms.
[12/14/2022, 10:39:21 PM] Loaded 0 cached accessories from cachedAccessories.
[12/14/2022, 10:39:21 PM] ---
[12/14/2022, 10:39:21 PM] No plugins found.
[12/14/2022, 10:39:21 PM] Loading 1 platforms...
[12/14/2022, 10:39:21 PM] Publishing bridge accessory (name: ds2, publishInfo: {
  username: 'CC:22:3D:E3:C7:3D',
  port: 51826,
  pincode: '***-**-***',
  category: 2,
  bind: undefined,
  mdns: undefined,
  addIdentifyingMaterial: true,
  advertiser: 'avahi'
}).
Setup Payload:
X-HM://00253QFZSWX86
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ 987-65-432 │     
    └────────────┘     
                       
2022-12-14T21:39:21.484Z HAP-NodeJS:Advertiser Detected Avahi over DBus interface running version 'avahi 0.7'.
2022-12-14T21:39:21.486Z HAP-NodeJS:Advertiser Preparing Advertiser for 'ds2 0BBB' using Avahi backend!
2022-12-14T21:39:21.491Z HAP-NodeJS:Advertiser Starting to advertise 'ds2 0BBB' using Avahi backend!
[12/14/2022, 10:39:21 PM] Homebridge v1.6.0 (HAP v0.11.0) (ds2) is running on port 51826.
Could not create mDNS advertisement. The HAP-Server won't be discoverable: Error: No such interface found

Configuration

{
    "bridge": {
        "name": "ds2",
        "username": "CC:22:3D:E3:C7:3D",
        "port": 51826,
        "pin": "987-65-432",
        "advertiser": "avahi"
    },
    "ports": {
        "start": 51850,
        "end": 51869
    },
    "plugins": [
        "homebridge-config-ui-x"
    ],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        }
    ],
    "accessories": []
}

Environment

  • OS: DSM 7.1.1-42962 Update 1
  • Software: Homebridge v1.6.0
  • Node: v16.17.1
  • npm: 8.19.2

Process Supervisor

hb-service

Additional Context

I think the check through dbus whether Avahi is running doesn't work on Synology. I do have a dbus process running, though.

@ebaauw
Copy link
Contributor Author

ebaauw commented Dec 14, 2022

For comparison, here's the log output in Homebridge v1.5.9:

[12/14/2022, 10:41:28 PM] [HB Supervisor] Restarting Homebridge...
[12/14/2022, 10:41:28 PM] [HB Supervisor] Starting Homebridge with extra flags: -P /volume1/homebridge/node_modules -D --strict-plugin-resolution
[12/14/2022, 10:41:28 PM] [HB Supervisor] Starting Homebridge with custom env: {"DEBUG":"HAP-NodeJS:Advertiser","NODE_OPTIONS":"--trace-warnings"}
[12/14/2022, 10:41:28 PM] [HB Supervisor] Started Homebridge v1.5.1 with PID: 27264
2022-12-14T21:41:29.027Z HAP-NodeJS:Advertiser Initializing HAP-NodeJS v0.10.4 ...
[12/14/2022, 10:41:29 PM] Loaded config.json with 0 accessories and 1 platforms.
[12/14/2022, 10:41:29 PM] Loaded 0 cached accessories from cachedAccessories.
[12/14/2022, 10:41:29 PM] ---
[12/14/2022, 10:41:29 PM] No plugins found.
[12/14/2022, 10:41:29 PM] Loading 1 platforms...
[12/14/2022, 10:41:29 PM] Publishing bridge accessory (name: ds2, publishInfo: {
  username: 'CC:22:3D:E3:C7:3D',
  port: 51826,
  pincode: '***-**-***',
  category: 2,
  bind: undefined,
  mdns: undefined,
  addIdentifyingMaterial: true,
  advertiser: 'avahi'
}).
Setup Payload:
X-HM://00253QFZSWX86
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ 987-65-432 │     
    └────────────┘     
                       
[12/14/2022, 10:41:29 PM] Homebridge v1.5.1 (HAP v0.10.4) (ds2) is running on port 51826.
2022-12-14T21:41:29.317Z HAP-NodeJS:Advertiser Detected Avahi over DBus interface running version 'avahi 0.7'.
2022-12-14T21:41:29.320Z HAP-NodeJS:Advertiser Preparing Advertiser for 'ds2 0BBB' using Avahi backend!
2022-12-14T21:41:29.326Z HAP-NodeJS:Advertiser Starting to advertise 'ds2 0BBB' using Avahi backend!

@Supereg
Copy link
Member

Supereg commented Dec 15, 2022

Reading the logs there are two important lines here:

2022-12-14T21:39:21.484Z HAP-NodeJS:Advertiser Detected Avahi over DBus interface running version 'avahi 0.7'.
[...]
Could not create mDNS advertisement. The HAP-Server won't be discoverable: Error: No such interface found

The last line refers to a feature failing introduced with PR #970 which registers to the Server.StateChanged interface to be notified about avahi server restarts.
Secondly, you/Synology are/is running avahi version 0.7 a 6 year old release of avahi. My test environment runs avahi 0.8 so I assume there is some issues with the exposed dbus interface that was updated in the avahi 0.8 release.
Within hap-nodejs, we are using the legacy org.freedesktop.Avahi.Server instead of the org.freedesktop.Avahi.Server2 interface that got introduced with 0.8. So I'm not sure if there are changes within the "legacy" interface that weren't properly communicated.

That's my currently analysis of the problem. I will investigate further. One possibility is to just gracefully continue if the dbus interface is not found, see:

this.avahiServerInterface = await AvahiAdvertiser.avahiInterface(this.bus, "Server");
this.avahiServerInterface.on("StateChanged", this.stateChangeHandler);
.

But ideally we find a solution that enables restart detection also for < avahi 0.8 daemons.

Thanks for reporting this issue 🚀

@Supereg
Copy link
Member

Supereg commented Dec 15, 2022

Looking at the diff between 0.7 and 0.8, there are now changes in regard to the dbus interface used: avahi/avahi@v0.7...v0.8#diff-cda9c20b8570353458c309abfcddcac2c9be7b6fca607ef7b702a7d489ed1648

@ebaauw
Copy link
Contributor Author

ebaauw commented Dec 15, 2022

Your test in the PR also uses avahi 0.7? See #970 (comment)

@Supereg
Copy link
Member

Supereg commented Dec 15, 2022

You are indeed right. I was probably still running ubuntu 20.04 back then.

Is there anyway to replicate the synology environment, is there a docker image or something?

@Supereg
Copy link
Member

Supereg commented Dec 15, 2022

For reference, the error comes from here within dbus-native:
https://github.com/homebridge/dbus-native/blob/fc1a5bf07b448f473923a64e707110e48f0272f6/lib/introspect.js#L33

It is called by introspectBus which is called by DBusService.getInterface(...)

@Supereg
Copy link
Member

Supereg commented Dec 15, 2022

You could try to manually debug, by adding a console.log(result); before that line, maybe (file node_modules/@homebridge/dbus-native/lib/introspect.ts).

@ebaauw
Copy link
Contributor Author

ebaauw commented Dec 15, 2022

I think Synology supports multiple DSM installations on the same DiskStation through virtualisation, but I never looked into that. I doubt DSM will run on non-Synology hardware.

In my experience, Synology tends to modify standard software, e.g. they run their own build of nut.

So “interface” in the error message refers to the dbus endpoint, not to the network interface.

@Supereg
Copy link
Member

Supereg commented Dec 15, 2022

So “interface” in the error message refers to the dbus endpoint, not to the network interface.

Exactly. And the issue also only evolves around the org.freedesktop.Avahi.Server interface of the org.freedesktop.Avahi service. We use that to subscribe to the StateChanged signal.

For our other commands we use the org.freedesktop.Avahi.Server (to check the version and create a new entry group) and org.freedesktop.Avahi.EntryGroup (adding the mDNS service and advertising it) interfaces. Though, in those instances we only do a request-response style of communication (in hap-nodejs this is implemented in AvahiAdvertiser.avahiInvoke). The StateChanged signal is the only occurrence where we actually subscribe to signals of an interface (implemented via AvahiAdvertiser.avahiInterface.

@ebaauw
Copy link
Contributor Author

ebaauw commented Dec 15, 2022

The result is just a newline. The xml reads:

<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
</node>

@Supereg
Copy link
Member

Supereg commented Dec 15, 2022

Hm. I mean, we could incorporate a workaround where we just don't care about hooking the StateChanged listener, maybe printing a little warning if we can't explaining that we won't be able to detect restarts.
But I would really interested why this doesn't work on Synology.
It's not about dbus itself is it (idk difference in version etc)? Maybe there is some issue within dbus-native? But the response is completely empty, so something must be going wrong even before that.

@ebaauw
Copy link
Contributor Author

ebaauw commented Dec 15, 2022

$ dbus-daemon --version
D-Bus Message Bus Daemon 1.12.16
Copyright (C) 2002, 2003 Red Hat, Inc., CodeFactory AB, and others
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

That's an old one, my Raspberry Pi servers running bullseye report 1.12.24 (with the same 2002, 2003 copyright message).

$ avahi-daemon --version
avahi-daemon 0.7

Nothing here that we didn't already know.

@Supereg
Copy link
Member

Supereg commented Dec 15, 2022

ping @adriancable, any ideas on this?

@github-actions
Copy link

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.

@github-actions github-actions bot added the stale label Jan 14, 2023
@Supereg Supereg added long running Issues which should be excluded from the stale bot and removed stale labels Jan 14, 2023
@Supereg
Copy link
Member

Supereg commented Apr 30, 2023

I installed a workaround in the latest beta release of hap-nodejs 0.11.1 and homebridhe 1.6.1.
See #1003.

@Supereg Supereg closed this as completed Apr 30, 2023
@Supereg Supereg removed the long running Issues which should be excluded from the stale bot label Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants