Issues with Spotify Connect server on Rpi3 with OSMC [Solved]

Hello,

I have an issue concerning spotify connect autostart on OSMC. I’m quite a noob concerning linux, but I’m trying. Since a while I have used Openelec with a Rpi 1 B+, but made the switch to OSMC on a new Rpi 3.

I wish to have use Kodi for movies and stuff, and use Spotify connect for listening music. My aim is to have the Rpi 24/7 running with Kodi and Spotiy simultaneous.

Installing OSMC was no problem.
Installing the spotify connect server web was no issue either (GitHub - Fornoth/spotify-connect-web).

I can start the spotify server on SSH with the command:
/home/osmc/spotify-connect-web.sh --username xxxxx --password xxxxx --bitrate 320 --name woonkamer

So far so good.

Now I want to make it autostart at startup, or at least keep the program running after closing the (SSH)terminal. Here the problems start.

I have tried multiple sollutions:
a. Edit local.rc (adding the following lines)

sleep 30
/home/osmc/spotify-connect-web.sh --username xxxxx --password xxxxx --bitrate 320 --name 

nothing happens

b. Making a script as in http://www.forum-raspberrypi.de/Thread-tutorial-spotify-connect-server-headless-standalone:

#!/bin/bash

/home/osmc/spotify-connect-web.sh --username xxxxx --password xxxx --bitrate 320 --name woonkamer

exit 0

Allthough the script results in the following errors:

mount: mount point /root/spotify-connect-web-chroot/dev does not exist
umount: /root/spotify-connect-web-chroot/dev: mountpoint not found
umount: /root/spotify-connect-web-chroot/proc: mountpoint not found

Anyone any idea what is going wrong?

I figured out how I can shutdown te terminal without ending the spotify server.
Adding & at the end of the command seemed to have worked.

/home/osmc/spotify-connect-web.sh --username xxxxx --password xxxx --bitrate 320 --name woonkamer &

Still no idea how to make it autostart.

I’ve managed to get it starting up on boot by following the instructions on https://discourse.osmc.tv/t/osmc-running-custom-script-at-boot/2425 to set up a service using the following:

[Unit]
Description=Spotify Connect Web
After=network-online.target

[Service]
ExecStart=/path/to/script
User=osmc

[Install]
WantedBy=multi-user.target

Thanks, but it’s still not working. I have the following setup:

I have a file /home/osmc/scs.sh:

#!/bin/bash

/home/osmc/spotify-connect-web.sh --username xxxxx--password xxxxx --bitrate 320 --name woonkamer $

exit 0

I did:

sudo chmod a+u /home/somc/scs.sh

I have also a file /etc/systemd/system/scs.service:

[Unit]
Description=Spotify Connect
After=network-online.target

[Service]
Type=idle
ExecStart=/home/osmc/spotify-connect-web.sh --username xxxxx–password xxxxx --bitrate 320 --name woonkamer
Restart=always
RestartSec=10
StartLimitInterval=30
StartLimitBurst=20

[Install]
WantedBy=multi-user.target

At the moment the file scs.sh isn’t used by the scs.service. It could, but I’m not sure it makes a difference.

After making this file, I did:
sudo systemctl daemon-reload
sudo systemctl enable scs.service

After sudo systemctl status scs.service, I get this report:

  • scs.service - Spotify Connect
    Loaded: loaded (/etc/systemd/system/scs.service; enabled)
    Active: activating (auto-restart) (Result: exit-code) since Sun 2016-04-17 14:59:24 CEST; 15s ago
    Main PID: 3919 (code=exited, status=64)

Apr 17 14:59:24 Woonkamer systemd[1]: Unit scs.service entered failed state.

So still no succes. Any ideas?

@blinks, what does your “/path/to/script” looks like? Is it a separate script, or do you use the spotify-connect-web.sh script?

Just got one step closer.

I wasn’t paying attention with blinks reply:
After adding “User=osmc” to scs.service the service actually started, although not the right way. Somehow the server still doesn’t appear as a spotify connect device at other clients, as is should.

After sudo systemctl status scs.service, I get this report:

  • scs.service - Spotify Connect
    Loaded: loaded (/etc/systemd/system/scs.service; enabled)
    Active: active (running) since Sun 2016-04-17 15:59:22 CEST; 1min 23s ago
    Main PID: 288 (spotify-connect)
    CGroup: /system.slice/scs.service
    |-288 /bin/bash /home/osmc/spotify-connect-web.sh --username xxxxx --password xxx
    |-354 sudo chroot /home/osmc/spotify-connect-web-chroot /bin/bash -c cd /usr/src/app &&…
    |-357 /bin/bash -c cd /usr/src/app && python main.py --username xxxxx --passwor…
    `-383 python main.py --username xxxxx --password xxxxx --bitrate 320 --name …

Apr 17 15:59:22 Woonkamer sudo[313]: osmc : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/mou…roc/
Apr 17 15:59:22 Woonkamer sudo[313]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 17 15:59:22 Woonkamer sudo[332]: osmc : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/cp …etc/
Apr 17 15:59:22 Woonkamer sudo[332]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 17 15:59:22 Woonkamer sudo[332]: pam_unix(sudo:session): session closed for user root
Apr 17 15:59:22 Woonkamer sudo[354]: osmc : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbi…amer
Apr 17 15:59:22 Woonkamer sudo[354]: pam_unix(sudo:session): session opened for user root by (uid=0)
Hint: Some lines were ellipsized, use -l to show in full.

Anyone know what’s happening here? And where is goes wrong?

Earlier I reported the system didn’t work with the reports above.
Nothing has really changed. The command sudo systemctl status scs.service still results in the same report.

Now I discover everything does work as it should. I can find the spotify connect in my android-client.

Have you ever managed to get it working (as in you could find the Spotify Raspberry Pi device via your smarthphone/tablet/desktop app?)?

As far as I know, the person that was reverse engineering Spotify Connect said it is still a work in progress:

And the person that is now making it possible to use librespot (the site you are referring to: GitHub - Fornoth/spotify-connect-web) doesn’t mention this, so probably it should work.

Sorry I didn’t reply sooner. Yes user=osmc was the key for me! All working here too.

@zilexa,

Yes. I have it working. And not only working, it does autostart as well.

So, currently I have a raspberry pi 3 with Kodi, which also works as a spotify connect server (although that’s only visible on my android Spotify-app and my windows 10 spotify-app).

If somehow the pi crashes, my wife can just reboot as usual (by pulling out and replugging the usb-power). After that everything works as it should. It shouldn’t be any harder for her…

Although te pi currently didn’t need a reboot yet. It’s active for about 48h.

Two important notices in addition to the previous :

  1. Important to enable the following in config.txt: HDMI_FORCE_HOTPLUG=1
    Without it I think the spotify-connect looses the audio-output through HDMI when you disable the tv. I’m not sure wat the settings should be if you use the jack-connector or an additional soundcard.
  2. Spotify allowes only one spotify-key per user. So if you wish to add more Rpi’s, you’re out of luck. I already tried that…

Maybe I can combine all the guides into one specific guide for Rpi+OSMC. But I need to find some time for it.

This should work with any device running OSMC. I am definitely going to install it on my RPi2 and RPi1 tonight!

@sam_nazarko would it not be a fantastic idea to add the above as an OSMC app in the OSMC store? This would be highly popular for all the Spotify Premium users that are now restricted to using Bluetooth. I will continue to use Bluetooth audio streaming for other audio sources. Spotify Connect would be fantastic, lower battery usage and no Bluetooth compression or issues with wifi interference. The phone/tablet/pc is only meant as a UI while the Spotify Connect server streams the music from the internet and plays it back.

Everything I did to get it work, you can find here: