mDNS Repeater and Spotify

My network is separated into multiple VLANs for clients, guests and devices.
The mDNS repeater is enabled between the VLANs.
The firewall blocks connections from devices to clients.
I have Yamaha amplifiers that support Spotify Connect on the device network.
I use Spotify on an iPhone on the device network.

I’ve been having trouble with Spotify not discovering the amplifiers when I try to connect to remote speakers. I could make it work by restarting the amplifier or restarting the mDNS repeater but it would then fail next time I tried to connect.

I’ve discovered that this is related to avahi’s caching of mDNS messages, not responding in the same way when using cached data.
I’ve been able to resolve this problem by disabling the cache by adding this to the avahi config file:

[server]
cache-entries-max=0

I’ve been able to make the configuration change persistent by adding a post commit hook:
/config/scripts/commit/post-hooks.d/avahi:

#!/bin/bash

CONFIG=/run/avahi-daemon/avahi-daemon.conf
AFTER=disallow-other-stacks=no
ADD=cache-entries-max=0

if ! grep -Fxq $ADD $CONFIG; then
    sudo sed -i "/$AFTER/a$ADD" $CONFIG
    sudo systemctl restart avahi-daemon
fi

Has anyone else had any similar problems?
Is there a better way to resolve this?
Is there a better way of making this persistent other than submitting a patch to add it to the config?

Thanks for posting this - I too was having problems where my Apple devices kept updating their host names with incrementing numbers because they thought the set hostname was already in use. By telling Avahi to not cache, the problem has gone away.

Seems like a good feature request to allow the mdns repeater to have a max-cache setting which can be set to 0 to disable or maybe a boolean to disable-cache. I haven’t grokked what the downside is to disabling the Avahi cache. Maybe someone who has more experience can indicate why the cache should not be disabled?

Thanks for describing the usecase, problem and also a potential fix.

I created a feature request ⚓ T6908 Avahi: add option to define mdns-repeater max-cache entries for this.

2 Likes
2 Likes