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

Improve Avahi interaction and handle dbus disconnection #24

Open
DerAndereAndi opened this issue May 4, 2024 · 1 comment
Open

Improve Avahi interaction and handle dbus disconnection #24

DerAndereAndi opened this issue May 4, 2024 · 1 comment
Labels
enhancement New feature or request mDNS mDNS related topics

Comments

@DerAndereAndi
Copy link
Member

DerAndereAndi commented May 4, 2024

The avahi service integration uses https://github.com/holoplot/go-avahi/ which communicates with the avahi daemon via dBUS.

When the dbus connection gets removed (e.g. avahi daemon stops, crashes, etc.), it will never reconnect. This needs to be improved/handled, and also made sure the SHIP service will be reannounced.

There is an issue for that already in the repository: holoplot/go-avahi#21

@DerAndereAndi DerAndereAndi added the enhancement New feature or request label May 4, 2024
DerAndereAndi added a commit to enbility/eebus-go that referenced this issue May 4, 2024
@DerAndereAndi DerAndereAndi added the mDNS mDNS related topics label May 4, 2024
@DerAndereAndi
Copy link
Member Author

I think this should be all done in the avahi library itself. Because also re-announcing services and re-starting running services needs be handled, as well as creating a new dbus connection when that is lost. Right now the dbus connection is passed as an argument, instead it should imho be handled by the library itself.

To what out for a dbus or avahi service disconnect, this code will help:

// Get signals for DBus Disconnects
dbusConn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, "type='signal',interface='org.freedesktop.DBus.Local'")
// Get signals for Avahi NameOwnerChanged
dbusConn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, "type='signal',interface='org.freedesktop.DBus'")

For dbus disconnects, the signal.Name value to watch out for is org.freedesktop.DBus.Local.Disconnected. For avahi re-/disconnects it is org.freedesktop.DBus.NameOwnerChanged. The avahi c library can be used as a reference.

In addition avahi offers an option to wait for a avahi dbus connection on startup. It might be a good idea to add this as an option for the avahi only mode as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mDNS mDNS related topics
Projects
None yet
Development

No branches or pull requests

1 participant