Multiple Instances #1444
-
@mikebrady , I am currently running multiple instances of SPS-AP2 in Docker containers using PulseAudio but I noticed in the What's New post you said that NQPTP has some changes that allow multiple instances to work on a single machine. You also said that clients get confused about multiple instances on the same machine. I gave this a spin and it does seem like the clients don't understand and one instance overwrites the last. So basically this is unusable, or is there a work around I'm missing? Looks like for now I will still need to use containers to run multiple instances. |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 26 replies
-
Hi Noel. Yes indeed, it seems that clients, including iOS and the Mac Music app, get confused by multiple instances on the same IP number. Unfortunately, it seems to be a dead end at the moment. |
Beta Was this translation helpful? Give feedback.
-
I wanted to revive this discussion and shed some new light with my recent findings. It appears that Airplay2 clients are not being confused by instances with the same IP address, rather by instances that share the same 'DeviceID' in their mDNS advertisement. I tested this by creating macvlan interfaces on my Linux machine and assigning unique IP addresses to each of them from my router's DHCP server. I then ran an instance of Shairport-Sync (with Airplay2 enabled) on each interface by providing them with different config files with "general.interface" set to the appropriate macvlan interface. I validated that each shairport-sync instance was advertising from the appropriate IP address by running tcpdump of mdns traffic on a separate machine. With that, I checked on my iPhone 13 Max Pro (iOS 15) for both instances and it showed only one appearing still in my Airplay menu. After failed test, I tried a different approach. I tried to modify the 'DeviceID' field advertised in the mDNS packet for the Shairport-Sync instance. To do this I overwrote the "general.airplay_device_id" field in the config file for each instance to be unique and I was finally able to see both instances appear in my airplay menu on my iPhone. My follow up questions are, would there by any unintended side effects of defining the airplay_device_id to be an arbitrary value? Would it affect streaming/controls at all? I will investigate further and provide my findings here. I'm also happy to provide more details as to how I tested this so people can reproduce this experiment. |
Beta Was this translation helpful? Give feedback.
-
Thanks for all this. I tried to explore this some time back and the Experiments seemed to show that AirPlay clients routinely confused two endpoints on the same IP even when they had different IDs. This happened with macOS and iOS clients. Of course I could be wrong. The thing is that since that time, NQPTP's ability to handle more than one client has been removed (greatly simplifying NQPTP), so the situation @noelhibbard describes now could easily be caused by one SPS instance turning off NQPTP, which would have the effect of turning it off for all instances. One could go back to previous versions of SPS and NQPTP, before the multi-client facility was removed from NQPTP, but there have been quite a few bug fixes since then. You might have seen that an AirPlay 2 version of SPS has just been released, so it will take some time to enable NQPTP to serve multiple instances of SPS again. SPS itself would have to be modified too, but that's much simpler. |
Beta Was this translation helpful? Give feedback.
-
Thank you @noelhibbard for digging into this and thank you @mikebrady for chiming in on this! Is there a timeline we can expect adding support for multiple SPS instances? Being able to launch multiple instances of SPS with Airplay2 without depending on Docker would simplify things drastically. It would also be nice to be able to provide device ID as a parameter on invocation from the command line, rather than creating separate config files for each instance. Understanding that you're probably very swamped with tons of other request, I'd also be happy if you could share the commit hash of the version of NQPTP that supported multiple instances of SPS (and perhaps what bugs to expect). |
Beta Was this translation helpful? Give feedback.
-
Update: I was finally able to test this out for myself and. I just so happened to be running an older version of NQPTP and shairport-sync AP2 that work well together and I was able to play multiple instances without the side effects @noelhibbard mentioned. NQPTP: Shairport-Sync: |
Beta Was this translation helpful? Give feedback.
-
If multiple instances on the same ip address is an issue, could it be possible to bind an instance to a specific ip address and allocate multiple ip addresses for example on a LXC container in proxmox? Allocation multiple networks which gets its own ip address and mac address is fairly easy at Proxmox, but I see no option to specifiy an ip address to shairport-sync. I have the following setup in my mind:
If this would be possible, a very nice multiroom audio setup can be created :-) Thanks a lot. Kind regards, |
Beta Was this translation helpful? Give feedback.
-
@CDaxi , I’ve had success with Proxmox, LXC and Docker. Getting complex ALSA configs to work in containers doesn’t work well though. I had to switch to Pulse to get my setup to work correctly. I prefer doing it in docker because I can manage all my instances in one docker-compose file. I’ve documented my setup here:
https://github.com/noelhibbard/sharport-sync-docker
I also run a Snapchat server and multiple instances of snapclient and librespot but I do that directly on the host.
|
Beta Was this translation helpful? Give feedback.
-
@noelhibbard, can you say more about the difficulties in working with the ALSA subsystem in Docker? What seems to be the problem? Thanks. |
Beta Was this translation helpful? Give feedback.
-
I'm currently using my method of running multiple instances of Airplay2 which involves manually specifying the device id and using an older version of nqptp/shairport-sync. It all works but I'm running into an issue where things start to get slow after I get to my 2nd or 3rd simultaneous Airplay2 input. It takes a while to disconnect from the Airplay2 instances and i have to wait until the busy spinner on the airplay screen goes away (presumably because something timed out) before I'm able to do anything again. After that, things remain slow to connect. Has anyone seen anything like this when running multiple Airplay2 instances? Could it have something to do with being on an older version of shaiport-sync/nqptp? |
Beta Was this translation helpful? Give feedback.
-
When I disconnect from multiple instances of shairport-sync by selecting 'iPhone' (rather than deselecting each input one by one), I get a pinwheel spinning indefinitely. When done from the control center, it renders Airplay selection inoperable. @noelhibbard Has this ever come up in your testing with your docker instances? |
Beta Was this translation helpful? Give feedback.
-
I've gotten multiple instances of shairport-sync to run in a docker-compose stack on a virtual network managed by docker. The host in this case is Ubuntu 22.04 LTS. I've posted my config in my repository for reference. Thanks to everyone for their efforts! |
Beta Was this translation helpful? Give feedback.
-
Beware that running multiple instances over WiFi does not work with docker and Macvlan. Ask me how I found out :( |
Beta Was this translation helpful? Give feedback.
-
So I thought I was clever and did the following:
Both AirPlay targets A and B show up. A being the original one running per usual, B being the new one in the namespace. Success? I select "B" to stream to from my phone, "B" immediately disappears and "A" is now selected and receiving the stream without me ever selecting it. There's other weird behaviour, but in short it always plays through "A" How is it that with a completely separate network stack, IP, MAC address and SMI path, devices are still getting confused between the two targets? What am I missing that's still common between the two? I'm determined to make this work without having to spin up a VM. |
Beta Was this translation helpful? Give feedback.
Hi Noel. Yes indeed, it seems that clients, including iOS and the Mac Music app, get confused by multiple instances on the same IP number. Unfortunately, it seems to be a dead end at the moment.