upmpdcli-docker icon indicating copy to clipboard operation
upmpdcli-docker copied to clipboard

A simple guide for connecting MPD and Navidrome running on 2 different computers

Open sergueif opened this issue 10 months ago • 28 comments

Hi Giovanni,

I know there's many different ways to use MPD and Navidrome and Upnp and all. There's "control point" stuff, etc. I've read the "frontend-vs-backend mpd intgration" page (https://www.lesbonscomptes.com/upmpdcli/pages/upmpdcli-or-mpdupnp.html). But I still can't figure out how to do the following:

  • I have navidrome happily running on computer A. it accesses media files on computer X via a samba share. I can play music on my phone via a subsonic client accessing this Navidrome instance
  • Computer X also has nice speakers connected to it. I play music on those by using MPD. in the current setup, MPD accesses the audio files via a local folder and has it's own DB in a file.
  • I want to deploy upmpdcli somewhere (could be computer X or another computer B, but probably not A, so as to not overload it) to make the MPD use Navidrome as it's database.

In the above setup, is it necessary to have upmpdcli also act as an audio file server? my MPD can already access the raw audio files because it's colocated with those. I just want MPD to have live access to the playlists that Navidrome maintains (some of which are "smart").

I managed to get upmpdcli running via Docker-compose on computer B and it prints a bunch of happy stuff like CMDTALK: subsonic-app.py: Processing genre [Instrumental Jazz] so I take it that means upmpdcli can access the content of my Navidrome. But now how do I connect the existing MPD instance to it? What's the minimal config for mpd.conf and for upmpdcli.conf?

I tried to do just the

database {
    plugin "upnp"
}

in mpd.conf, but that seems to fail with:

exception: Failed to open database plugin; UpnpInit() failed: UPNP_E_SOCKET_BIND

also, I can't seem to see the docker-compose instance of upmpdcli on the iOS UPnP Mate app. But when i did another experiment and ran UPnP without docker on Computer X, then I can see the upmpdcli "Media Server" listed in upnp Mate.

Anyway, much appreciate you doing the subsonic upmpdcli plugin so that there's hope of connecting MPD to Navidrome. All I want is to use MPD "as a client to" Navidrome (and then ncmpcpp "as a client/remote to" MPD).

sergueif avatar Apr 17 '25 15:04 sergueif

Hi Giovanni,

Hello!

I know there's many different ways to use MPD and Navidrome and Upnp and all. There's "control point" stuff, etc. I've read the "frontend-vs-backend mpd intgration" page (https://www.lesbonscomptes.com/upmpdcli/pages/upmpdcli-or-mpdupnp.html). But I still can't figure out how to do the following:

* I have navidrome happily running on computer `A`. it accesses media files on computer `X` via a samba share. I can play music on my phone via a subsonic client accessing this Navidrome instance

Perfect.

* Computer `X` also has nice speakers connected to it. I play music on those by using MPD. in the current setup, MPD accesses the audio files via a local folder and has it's own DB in a file.

So that is your player, ok.

* I want to deploy `upmpdcli` somewhere (could be computer `X` or another computer `B`, but probably not `A`, so as to not overload it) to make the MPD use Navidrome as it's database.

You can deploy upmpdcli on computer "X" and make your mpd instance available as a UPnP renderer. If that is the only player, it might make sense that the upmpdcli instance would run the subsonic plugin. It should not overload your player unless it's very underpowered. If you have more than one player, it might be a good idea to install upmpdcli with the subsonic plugin as a media server on computer "B", which does not need to have a DAC/Speakers. So you don't need to run distinct media servers with the same subsonic plugin connected to the same Navidrome instance. It's up to you, and depends on your setup and your preference.

In the above setup, is it necessary to have upmpdcli also act as an audio file server? my MPD can already access the raw audio files because it's colocated with those. I just want MPD to have live access to the playlists that Navidrome maintains (some of which are "smart").

The navidrome playlist should be available through the media server which will run the upmpdcli plugin! I don't know a lot of the "smart" playlists, but regular one used to work when I tried them.

I managed to get upmpdcli running via Docker-compose on computer B and it prints a bunch of happy stuff like CMDTALK: subsonic-app.py: Processing genre [Instrumental Jazz] so I take it that means upmpdcli can access the content of my Navidrome. But now how do I connect the existing MPD instance to it? What's the minimal config for mpd.conf and for upmpdcli.conf?

I tried to do just the

database {
    plugin "upnp"
}

in mpd.conf, but that seems to fail with:

exception: Failed to open database plugin; UpnpInit() failed: UPNP_E_SOCKET_BIND

That is not needed... it was used to replace mpd's own db system with upnp. I never use it, its functionality can be easily replaced by a control point like BubbleUPnP, mConnect, upplay, etc. About the minimal config: if your mpd install plays regularly, most likely it's ok already. You only need to check that it's available over the network, e.g. the mpd.conf should contain something like:

bind_to_address "any"
port "6600"

or

bind_to_address "0.0.0.0"
port "6600"

also, I can't seem to see the docker-compose instance of upmpdcli on the iOS UPnP Mate app. But when i did another experiment and ran UPnP without docker on Computer X, then I can see the upmpdcli "Media Server" listed in upnp Mate.

AFAIK upnp mate is not the type of app you need. That's a generic upnp app, not specifically built for audio. Maybe use mConnect lite here

Anyway, much appreciate you doing the subsonic upmpdcli plugin so that there's hope of connecting MPD to Navidrome.

All I want is to use MPD "as a client to" Navidrome (and then ncmpcpp "as a client/remote to" MPD).

So, should you want to start with an instance of upmpdcli on the player itself, use this sample.

You just need to copy sample.env to .env and tune your settings there, then start the container. In particular, in order to connect to the mpd instance on the same host (localhost), you need to make sure that RENDERER_MODE is set to UPNPAV or BOTH, as OpenHome is not supported by mConnect lite afaik). Variables MPD_HOST and MPD_PORT are set by default to localhost and 6600, so defaults are ok if you run this container on the player. But you can change MPD_HOST according to the player IP if you want to install it on another device.

Make sure to set the variables:

# SUBSONIC_BASE_URL=https://192.168.1.10

# Mandatory to set!
# Port of your subsonic server
# Example: Navidrome's default port is 4533, Lightweight Music Server is 5082
# Use 443 if you have some sort of reverse proxy and are using https://... for SUBSONIC_BASE_URL
# SUBSONIC_PORT=4533

# Mandatory to set!
# SUBSONIC_USER=your-username

# Mandatory to set!
# SUBSONIC_PASSWORD=your-password

# Mandatory to set in some cases: Lightweight Music Server requires this to be set to true
# It is false if not specified
# SUBSONIC_LEGACYAUTH=false

you can skip the SUBSONIC_LEGACYAUTH with Navidrome, it's not needed (the default is ok).

When this works, you might consider to only put upmpdcli in renderer mode (so removing all the subsonic stuff) on the player, and then run the media server with subsonic enabled but with renderer disabled (RENDERER_MODE) on some other device, so the media server is available to multiple players.

Let me know if this helps!

GioF71 avatar Apr 17 '25 16:04 GioF71

Rigelian seems to also be a good control point app.

GioF71 avatar Apr 17 '25 16:04 GioF71

Thank you very much for a reply! I'll try this after work tonight or tomorrow. Using upmpdcli as just a "database" for MPD was kinda appealing because then I can use most of the rest of the MPD ecosystem of apps. But i get a feeling like the upnp MPD database plugin is not a very popular or upkept way of doing this. So I'll try instead to use mpd as just a renderer and control playback/queue using some of these UPnP iOS apps

sergueif avatar Apr 17 '25 16:04 sergueif

Thank you very much for a reply! I'll try this after work tonight or tomorrow. Using upmpdcli as just a "database" for MPD was kinda appealing because then I can use most of the rest of the MPD ecosystem of apps. But i get a feeling like the upnp MPD database plugin is not a very popular or upkept way of doing this. So I'll try instead to use mpd as just a renderer and control playback/queue using some of these UPnP iOS apps

That's the most flexible solution, that also does not exclude to add the actual files (via samba maybe) to the mpd instance. Having more that one player, I don't like to use the raw mpd music db, because I would have to maintain a bunch of different libraries (but for the same set of files!).

GioF71 avatar Apr 17 '25 17:04 GioF71

Ah, btw, you can also create a media server from files using upmpdcli, using uprcl. Sample configuration here. As you want to use the Navidrome library, you probably don't want to use this, but it's a nice alternative.

GioF71 avatar Apr 17 '25 17:04 GioF71

ok, so I tried it quick right away. Here's why entire /etc/upmpdcli.conf (and I did a sudo systemctl restart upmpdcli on computer X that has the MPD on it)

logfilename = /var/log/upmpdcli.log
upnplogfilename= /var/log/upmpd-cli-libnpupnp.log
upnpav = 1
openhome = 0
msfriendlyname = NaviUPnP
uprcltitle = Local Music
upradiostitle = Upmpdcli Radio List
subsonicautostart = 1
subsonicuser = demo
subsonicpassword = demo
subsonicbaseurl = https://demo.navidrome.org
subsonicport = 433

I'm trying first using the Demo server

but mconnectLite iOS app says "Service login or communication failure" when I try to "Browse" the NaviUPnP .

sergueif avatar Apr 17 '25 17:04 sergueif

Hello, the default port is 443 for https, not 433, maybe that's the issue. Post the docker compose logs if this does not work.

GioF71 avatar Apr 17 '25 17:04 GioF71

Thank you for that 443 vs 433 thing. I changed it to 443 but still get same error on the iOS app.

I'm not using docker-compose anymore for this, but rather just the Debian bookworm upmpdcli package. the content of /var/log/upmpdcli.log is

:3:../libupnpp/upnpplib.cxx:273::LibUPnP: Using IPV4 192.168.2.43 port 49152 IPV6  port 49152
:2:../src/mediaserver/cdplugins/cmdtalk.cpp:190::CmdTalk::talk: command exited
:3:../src/mediaserver/cdplugins/cmdtalk.cpp:93::CmdTalk: command failed, not restarting
:2:../src/mediaserver/cdplugins/plgwithslave.cxx:235::PlgWithSlave::maybeStartCmd: startCmd failed
:3:../src/upmpd.cxx:312::checkContentFormat: format check disabled
:2:../src/mpdcli.cxx:336::(m_lastinsertid = mpd_run_add_id_to(m_conn, uri.c_str(), (unsigned)pos)) != -1 failed: No such song
:2:../src/mpdcli.cxx:339::(m_lastinsertid = mpd_run_add_id_to(m_conn, uri.c_str(), (unsigned)pos)) != -1 server error: 50
:2:../libupnpp/device/devdevice.cxx:468::UpnpDevice: Action failed:  code -911
:3:../src/upmpd.cxx:312::checkContentFormat: format check disabled
:2:../src/mpdcli.cxx:336::(m_lastinsertid = mpd_run_add_id_to(m_conn, uri.c_str(), (unsigned)pos)) != -1 failed: No such song
:2:../src/mpdcli.cxx:339::(m_lastinsertid = mpd_run_add_id_to(m_conn, uri.c_str(), (unsigned)pos)) != -1 server error: 50
:2:../libupnpp/device/devdevice.cxx:468::UpnpDevice: Action failed:  code -911
:3:../src/upmpd.cxx:312::checkContentFormat: format check disabled
:2:../src/mpdcli.cxx:336::(m_lastinsertid = mpd_run_add_id_to(m_conn, uri.c_str(), (unsigned)pos)) != -1 failed: No such song
:2:../src/mpdcli.cxx:339::(m_lastinsertid = mpd_run_add_id_to(m_conn, uri.c_str(), (unsigned)pos)) != -1 server error: 50
:2:../libupnpp/device/devdevice.cxx:468::UpnpDevice: Action failed:  code -911
:3:../src/upmpd.cxx:312::checkContentFormat: format check disabled
:2:../src/mpdcli.cxx:336::(m_lastinsertid = mpd_run_add_id_to(m_conn, uri.c_str(), (unsigned)pos)) != -1 failed: No such song
:2:../src/mpdcli.cxx:339::(m_lastinsertid = mpd_run_add_id_to(m_conn, uri.c_str(), (unsigned)pos)) != -1 server error: 50
:2:../libupnpp/device/devdevice.cxx:468::UpnpDevice: Action failed:  code -911

sergueif avatar Apr 17 '25 17:04 sergueif

Hello, at least you should be able to navigate the library in mConnect, is that right? Can you post your mpd.conf file? I forgot to mention, the "curl" input must be enabled

GioF71 avatar Apr 17 '25 17:04 GioF71

mpd.conf:

music_directory                 "/srv/dev-disk-by-uuid-51138595-117d-444b-baba-bc4a7e092d8d/library/audio-music"
playlist_directory              "/var/lib/mpd/playlists"
db_file                         "/var/lib/mpd/tag_cache"
log_file                        "/var/log/mpd.log"
state_file                      "/var/lib/mpd/state"
sticker_file                    "/var/lib/mpd/sticker.sql"
user                            "mpd"
bind_to_address                 "0.0.0.0"
filesystem_charset              "UTF-8"

# database {
#     plugin "upnp"
# }

auto_update "yes"
replaygain "off"
volume_normalization "no"

audio_output {
        type "alsa"
        name "Alsa"
        device "hw:2"
        mixer_type "hardware"
}

I'll try to enable curl now

Hello, at least you should be able to navigate the library in mConnect, is that right? I'm not quite sure. NaviUpnp shows up under "Local Server", then there's Subsonic folder under that, but then after clicking "Subsonic", I get the Service login or commnication failure

sergueif avatar Apr 17 '25 17:04 sergueif

Update: I tried adding

input {
    plugin "curl"
 }

but didn't help. I'm not sure if the issue is between mConnect and upmpdcli or between upmpdcli and the Navidrome instance

sergueif avatar Apr 17 '25 17:04 sergueif

uhm, demo instance of navidrome doesn't work for me as well. I must investigate and see if I can do something about it. Can you try against you self-hosted instance of navidrome? This is working for me!

GioF71 avatar Apr 17 '25 17:04 GioF71

I tried against my personal Navidrome instance and no luck, same error. Is there some debug tool to zero in on whether the issue is in client->upmpdcli or upmpdcli->Navidrome?

sergueif avatar Apr 17 '25 17:04 sergueif

When I use other apps like Rigelian and foobar2000, the "Media Server" shows up, but the "Subsonic" folder under it is empty. Seems that whenever I try to access the server using an iOS app, this shows up in the ucmpdcli logs:

:3:../libupnpp/upnpplib.cxx:273::LibUPnP: Using IPV4 192.168.2.43 port 49152 IPV6  port 49152
:2:../src/mediaserver/cdplugins/cmdtalk.cpp:190::CmdTalk::talk: command exited
:3:../src/mediaserver/cdplugins/cmdtalk.cpp:93::CmdTalk: command failed, not restarting
:2:../src/mediaserver/cdplugins/plgwithslave.cxx:235::PlgWithSlave::maybeStartCmd: startCmd failed
:3:../src/mediaserver/cdplugins/cmdtalk.cpp:93::CmdTalk: command failed, not restarting
:2:../src/mediaserver/cdplugins/plgwithslave.cxx:235::PlgWithSlave::maybeStartCmd: startCmd failed

sergueif avatar Apr 17 '25 17:04 sergueif

I tried the radio-browser and radio-paradise plugins (installed via Debian packages):

radio-browseruser=abc123
radio-browsertitle=foo
radio-browsercountry=CA
radio-paradiseuser=barradio

radio-browser didn't work. Same error as Subsonic. But radio-paradise worked! It's playing audio using the MPD on computer X. Maybe that can give some hint.

sergueif avatar Apr 17 '25 18:04 sergueif

I notice that both subsonic and radio-browser plugin mention needing extra python packages. Are those not included in the debian packages like upmpdcli-subsonic and upmpdcli-radio-browser?

I can't do pip3 install py-sonic on this debian instance. it wants me to use a python venv. If I make a venv and install python packages there, how can i tell upmpdcli to use that venv for it's python stuff?

sergueif avatar Apr 17 '25 18:04 sergueif

I did sudo pip3 install --break-system-packages pyradios and sudo pip3 install --break-system-packages py-sonic subsonic-connector and that did it. My bad. I assumed that the debian packages also somehow brought in the python packages.

Subsonic is working now. It's too bad I can't use ncmpcpp to manage the MPD queue, but I guess I'll explore all these UPnP players on ios and linux

sergueif avatar Apr 17 '25 19:04 sergueif

also, is there really slim hope of making upmpdcli just a "database" for MPD? the upnp "database plugin".

sergueif avatar Apr 17 '25 19:04 sergueif

Fascinating. Some apps, like mConnect on iOS, when playing a "playlist" just put 1 track into MPD queue and keep a separate queue (whole playlist) local to itself. But Linn on iOS does a nicer thing and put the whole playlist into the MPD queue. This is quite nice cause then I can use ncmpcpp to manage the queue, play/pause, etc.

sergueif avatar Apr 17 '25 19:04 sergueif

I did sudo pip3 install --break-system-packages pyradios and sudo pip3 install --break-system-packages py-sonic subsonic-connector and that did it. My bad. I assumed that the debian packages also somehow brought in the python packages.

Subsonic is working now. It's too bad I can't use ncmpcpp to manage the MPD queue, but I guess I'll explore all these UPnP players on ios and linux

I thought you were using the docker image. With that you don't need to install the extra packages!

GioF71 avatar Apr 17 '25 19:04 GioF71

Fascinating. Some apps, like mConnect on iOS, when playing a "playlist" just put 1 track into MPD queue and keep a separate queue (whole playlist) local to itself. But Linn on iOS does a nicer thing and put the whole playlist into the MPD queue. This is quite nice cause then I can use ncmpcpp to manage the queue, play/pause, etc.

yes, with UPnP-AV, the playlist is in the control point, with OpenHome, it's in the renderer!

GioF71 avatar Apr 17 '25 19:04 GioF71

also, is there really slim hope of making upmpdcli just a "database" for MPD? the upnp "database plugin".

Well there's uprcl. But you can still use MPD clients and access mpd database and music files ...

GioF71 avatar Apr 17 '25 19:04 GioF71

I notice that both subsonic and radio-browser plugin mention needing extra python packages. Are those not included in the debian packages like upmpdcli-subsonic and upmpdcli-radio-browser?

No they are not included in the packages because they are not available on the repositories I believe, but they are included in the docker images.

I can't do pip3 install py-sonic on this debian instance. it wants me to use a python venv. If I make a venv and install python packages there, how can i tell upmpdcli to use that venv for it's python stuff?

well you can create a venv as usual, activate it, and then run upmpdcli from that shell. In a systemd unit, you can do that by prepending something like

PATH=%h/your-venv/bin:$PATH upmpdcli <your-upmpdcli.conf>

So that you don't need to install python packages with scary --break-system-packages

GioF71 avatar Apr 17 '25 19:04 GioF71

demo

I got the demo navidrome working again with the docker image using a different PORT_OFFSET (9 in my case). This can happen if you run more instances of upmpdcli on the same device.

GioF71 avatar Apr 17 '25 19:04 GioF71

I did sudo pip3 install --break-system-packages pyradios and sudo pip3 install --break-system-packages py-sonic subsonic-connector and that did it. My bad. I assumed that the debian packages also somehow brought in the python packages.

Subsonic is working now. It's too bad I can't use ncmpcpp to manage the MPD queue, but I guess I'll explore all these UPnP players on ios and linux

yes, when using media servers, I think ncmpcpp and other command line apps can't easily add tracks from the media servers to the playlist. They should be able to play any item in the play queue though, but yes, they are designed to work with mpd and its own library. When using upnp, it's better to use a Control Point app-.

GioF71 avatar Apr 17 '25 19:04 GioF71

Hello, so is everything working now?

GioF71 avatar Apr 18 '25 10:04 GioF71

Hi Giovanni, yes thank you very much for helping me set this up!

sergueif avatar Apr 18 '25 13:04 sergueif

Awesome! I hope you can give me some feedback about how the plugin works for you. Feature requests are welcome. It has been built for my needs so your feedback is precious.

If you are using docker, you can always use the "master" images which are more up-to-date. The latest versions are always based on the latest version of the upstream upmpdcli (currently 1.9.3).

Please star the repo if you like the work!

GioF71 avatar Apr 18 '25 13:04 GioF71