Skip to content

Conversation

@skrashevich
Copy link
Contributor

@skrashevich skrashevich commented Jul 28, 2024

Overview

This PR addresses the error ERR internal/homekit/homekit.go:128 > error="no interfaces for listen" on macOS when running the application without root privileges.

Problem

The mDNS client was failing to bind to network interfaces, resulting in the error mentioned above. This typically occurred when specific network interfaces were not available or the address was already in use.

Solution

  • Address Reuse Handling:

    • Added a check for the "address already in use" error, allowing the loop to continue and try other interfaces.
  • Fallback for No Interfaces:

    • Implemented a fallback mechanism to use the system's default network interface if specific interfaces are not available.

Impact

These changes ensure that the mDNS client can gracefully handle common networking issues on macOS, improving reliability when the application is run without root privileges.
Fixes #1225

@AlexxIT AlexxIT self-assigned this Jul 28, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Feb 21, 2025

How can I replicate this error on my mac? I have go2rtc running with no errors. Without sudo.

AlexxIT added a commit to skrashevich/go2rtc that referenced this pull request Oct 15, 2025
@AlexxIT AlexxIT force-pushed the fix-multicast-macos branch from 15b54ae to efb1ae1 Compare October 15, 2025 12:57
if err != nil {
return errors.New("no interfaces for listen and fallback failed: " + err.Error())
}
b.Sends = append(b.Sends, conn)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work. We need networks. They are used further in the logic.

conn, err := lc1.ListenPacket(ctx, "udp4", ipn.IP.String()+":5353") // same port important
if err != nil {
if strings.Contains(err.Error(), "address already in use") {
continue
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useless

return
}

func InterfacesIP4() ([]net.IP, error) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useless

@AlexxIT AlexxIT removed their assignment Oct 15, 2025
@AlexxIT AlexxIT added the doubt label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using go2rtc for HomeKit in MacOS Sonoma

2 participants