mDNS discovery work on shell, but not in LaunchAgent
2
votes
2
answers
62
views
I've built a simple Python script that tries to discover my Sonos speakers via mDNS/UPnP/Bonjour and set some music sources to them. This is done using the [soco](https://soco.readthedocs.io/en/latest/getting_started.html) lib.
The script works well when started on the shell.
Starting it from a LaunchAgent (same machine, same user), it can't find the speakers.
import soco
from soco import discovery
found_speakers = discovery.discover(timeout=30)
Label
sonos
ProgramArguments
/usr/local/bin/poetry
run
sonos-sanitizer
RunAtLoad
StandardErrorPath
/var/log/sonos/sonos.stderr
StandardOutPath
/var/log/sonos/sonos.stdout
StartCalendarInterval
Hour
5
Minute
35
WorkingDirectory
/Users/xxx/Code/sonos_sanitzer
I'm a bit puzzled as of why it doesn't seem to get network access when run via LaunchAgent. I've even extended the discovery timeout to 30 seconds.
System is macOS 15 Sequoia.
Caveat: The Mac is connected to multiple networks using VLANs.
Asked by MerlinDE
(151 rep)
May 17, 2025, 03:08 PM
Last activity: May 24, 2025, 08:11 AM
Last activity: May 24, 2025, 08:11 AM