stephen / airsonos

:musical_note: AirPlay to Sonos
MIT License
2.1k stars 252 forks source link

airsonos on Synology #22

Open ghost opened 10 years ago

ghost commented 10 years ago

A great tool, I enjoy day by day, but the mac needs to run all the time. My Synology is running 24/7, so why not running there? as node.js can be installed on the synology, can airsonos run on that one as well?

stephen commented 10 years ago

Synology runs a linux-variant I believe, so theoretically yes. AirSonos has a few dependencies that you will need to find packages for, or compile yourself on Linux.

For reference, I know that on a clean Ubuntu box, you need to install at least: libavahi-compat-libdnssd-dev, and libasound2-dev to get AirSonos working.

Let me know how it goes and we can documents steps for others to use.

dinomite commented 10 years ago

@Skyryser Did it work on your Synology?

If not, another low power option is to use a Raspberry Pi or Beagle Bone. Someone even has a tutorial for running AirSonos on Raspberry Pi.

hanssens commented 10 years ago

Indeed, Synology runs on a stripped, bare-boned version of Debian. The main problem seems to be the lack of having apt-get, ipkg or similar package managers. Considering we're also missing some other vital stuff on a basic DiskStation instance, I've managed to do the following to perhaps get us a step further:

  1. Enable SSH on the DiskStation
  2. Install Python 2.7 (through the SynoCommunity Packages)
  3. Install Debian Chroot (through the SynoCommunity Packages)
  4. Reboot (= important)
  5. SSH with root onto your DiskStation using: ssh root@your_synology_ip

Now, in theory we should have access to chroot and therefor have access to apt-get. Unfortunately, on my Synology this is where I'm stuck on, up on to this moment. According to the Debian Chroot documentation (for Synology), I should be able to chroot using:

/var/packages/debian-chroot/scripts/start-stop-status chroot

This works. But running aptitude update or apt-get update doesn't really work.

Perhaps others can give some tips to extend these steps a bit further?

dejongrr commented 9 years ago

@hanssens, I was able to get it working using this site: https://github.com/SynoCommunity/spksrc/blob/develop/spk/debian-chroot/src/app/help/enu/index.html

I managed to use apt-get udpate and upgrade. Also, libavahi-compat-libdnssd-dev, and libasound2-dev are installed. But when I try to install airsonos, I am getting the error below:

DiskStation> npm install airsonos -g

ursa@0.8.0 install /usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/ursa node-gyp configure build && node install.js

gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "python2", you can set the PYTHON env variable. gyp ERR! stack at failNoPython (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:103:14) gyp ERR! stack at /volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:42:11 gyp ERR! stack at F (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/which/which.js:43:25) gyp ERR! stack at E (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/which/which.js:46:29) gyp ERR! stack at /volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/which/which.js:57:16 gyp ERR! stack at Object.oncomplete (evalmachine.:107:15) gyp ERR! System Linux 3.2.40 gyp ERR! command "node" "/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build" gyp ERR! cwd /volume1/@appstore/Node.js/usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/ursa gyp ERR! node -v v0.10.30 gyp ERR! node-gyp -v v0.13.1 gyp ERR! not ok npm ERR! Error: ENOENT, open '/usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns/build/Release/obj.target/dns_sd_bindings/src/mdns_utils.o' npm ERR! If you need help, you may report this entire log, npm ERR! including the npm and node versions, at: npm ERR! http://github.com/npm/npm/issues

etc. etc.


Any help would be very appreciated!

stephen commented 9 years ago

gyp ERR! stack Error: Can't find Python executable "python2", you can set the PYTHON env variable.

@dejongrr - I believe node-gyp requires python installed in order to build some packages

dejongrr commented 9 years ago

I took a look at: https://github.com/TooTallNate/node-gyp/ And based on the info, I used the following command:

DiskStation> npm config set python /volume1/@appstore/python/bin/python2.7

After some minutes I got the following:

ursa@0.8.0 install /usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/ursa node-gyp configure build && node install.js

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.10.30" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/ursa/.node-gyp" gyp ERR! build error gyp ERR! stack Error: not found: make gyp ERR! stack at F (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/which/which.js:43:28) gyp ERR! stack at E (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/which/which.js:46:29) gyp ERR! stack at /volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/which/which.js:57:16 gyp ERR! stack at Object.oncomplete (evalmachine.:107:15) gyp ERR! System Linux 3.2.40 gyp ERR! command "node" "/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build" gyp ERR! cwd /volume1/@appstore/Node.js/usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/ursa gyp ERR! node -v v0.10.30 gyp ERR! node-gyp -v v0.13.1 gyp ERR! not ok npm WARN deprecated static-favicon@1.0.2: use serve-favicon module

mdns@2.2.0 install /usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns node-gyp rebuild

gyp ERR! UNCAUGHT EXCEPTION gyp ERR! stack Error: ENOENT, no such file or directory gyp ERR! stack at process.cwd (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:8:19) gyp ERR! stack at Object.exports.resolve (path.js:309:52) gyp ERR! stack at configure (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:26:23) gyp ERR! stack at Object.self.commands.(anonymous function) as configure gyp ERR! stack at run (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:72:30) gyp ERR! stack at process._tickCallback (node.js:419:13) gyp ERR! System Linux 3.2.40 gyp ERR! command "node" "/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"

/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:8 cwd = origCwd.call(process) ^ Error: ENOENT, no such file or directory at process.cwd (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:8:19) at errorMessage (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:119:28) at issueMessage (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:125:3) at process. (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:109:3) at process.emit (events.js:95:17) at process._fatalException (node.js:272:26)

lame@1.0.3 install /usr/lib/node_modules/airsonos/node_modules/nicercast/node_modules/lame node-gyp rebuild

gyp ERR! UNCAUGHT EXCEPTION gyp ERR! stack Error: ENOENT, no such file or directory gyp ERR! stack at process.cwd (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:8:19) gyp ERR! stack at Object.exports.resolve (path.js:309:52) gyp ERR! stack at configure (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:26:23) gyp ERR! stack at Object.self.commands.(anonymous function) as configure gyp ERR! stack at run (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:72:30) gyp ERR! stack at process._tickCallback (node.js:419:13) gyp ERR! System Linux 3.2.40 gyp ERR! command "node" "/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"

/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:8 cwd = origCwd.call(process) ^ Error: ENOENT, no such file or directory at process.cwd (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:8:19) at errorMessage (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:119:28) at issueMessage (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:125:3) at process. (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:109:3) at process.emit (events.js:95:17) at process._fatalException (node.js:272:26) npm ERR! ursa@0.8.0 install: node-gyp configure build && node install.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the ursa@0.8.0 install script. npm ERR! This is most likely a problem with the ursa package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp configure build && node install.js npm ERR! You can get their info via: npm ERR! npm owner ls ursa npm ERR! There is likely additional logging output above. npm ERR! System Linux 3.2.40 npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "airsonos" "-g" npm ERR! cwd /root npm ERR! node -v v0.10.30 npm ERR! npm -v 1.4.21 npm ERR! code ELIFECYCLE

lame@1.1.1 install /usr/lib/node_modules/airsonos/node_modules/lame node-gyp rebuild

Btw, I used a node.js package for my ds214play (evansport): Node.js-evansport-0.10.29-0003

knusprig55 commented 9 years ago

@dejongrr try running the npm command with sudo or as root.

dejongrr commented 9 years ago

I am connected to my Synology with SSH using root@DiskStation.local, so in my understanding every command is already run as root. Could it be that somehow the ownership got changed, and therefore needs to be changed by chown on .node-gyp folder?

stephen commented 9 years ago

gyp ERR! stack Error: not found: make

is make in your path?

dejongrr commented 9 years ago

I used: apt-get install build-essential Packages like 'make' and 'g++' were installed witch were apparently essential to node-gyp, but I still getting to same error.

stephen commented 9 years ago

@dejongrr - Can you verify that make can be found? (which make)

Though installed, it seems node-gyp can't access the build tools it needs - that might be a more conducive place to look.. (i.e. I'm assuming other packages like npm install ursa also fail because your build env is still lacking something..)

dejongrr commented 9 years ago

Oke, so I started again and I think all is good now. It turned out that I installed node on my Synolody OS instead of debian chroot. These are the steps I took:

- Install debian package
- After the install, it will continue to install in the background, so check the cpu.
- When the CPU is down again, restart your synology Nas
- Login using SSH as root
- Type: 
/var/packages/debian-chroot/scripts/start-stop-status chroot
- Type: echo "deb htpp://ftp.nl.debian.org/debian stable main non-free" > /etc/apt/source.list
- Type: apt-get update
- Type: apt-get upgrade
- You might get some errors ragarding Locales.
- Type: apt-get install locales
- Type: dpkg-reconfigure localese
- Choose your locales with space and enter (I used en_US en_GB and nl_NL)
- Type: dpkg-reconfigure tzdata
- Choose your timezone
- Type: apt-get install build-essential
- Type: apt-get install curl
- Type: curl -sl https://deb.nodesource.com/setup | bash -
- Type: apt-get install nodejs
- Type: apt-get install libavahi-compat-libdnssd-dev libasound2-dev
- Type: npm install airsonos -g
- Type: airsonos

Do only error I get now is: * WARNING * The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs * WARNING * The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister

I googled around a bit and don't think it will cause any issues. I can see my sonos systems, but since I am not at home at the moment, I can't check if it really works. I'll post an update.

dejongrr commented 9 years ago

I can confirm it works! Thanks for the feedback! Next step for me will be to auto start debian chroot and airsonos when I reboot my Synology nas.

coolcatiger commented 9 years ago

Thanks for detailed instructions. I got it running on synology from SSH (using this i need to keep my mac running all the time).

I am trying to use debian chroot console to start airsonos. Has any one tried it ? If yes please share detailed instructions.

It could be useful to know instructions to start airsonos on synology automatically but it is totally fine to run it in background manually.

stephen commented 9 years ago

@dejongrr - nice work on this! I'll have to see about putting together guides for these in some central manner (and incl. your work) - maybe under the github wiki, or as markdown file in the project?

dejongrr commented 9 years ago

Don't know when the issue started, but I'm getting the following error:

root@DiskStation:/# airsonos
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
Searching for Sonos devices on network...
Setting up AirSonos for Living Room {192.168.2.102:1400}

Error: dns service error: unknown
    at new Advertisement (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns/lib/advertisement.js:56:10)
    at Object.create [as createAdvertisement] (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns/lib/advertisement.js:64:10)
    at NodeTunes.<anonymous> (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/server.js:65:21)
    at Server.g (events.js:180:16)
    at Server.EventEmitter.emit (events.js:92:17)
    at net.js:1055:10
    at process._tickCallback (node.js:419:13)

I am running the latest version of airsonos. It seems that airsonos is able the find all my sonos devices, but they doesn't show up under output devices on my mac.

See the diagnostics below:

AirSonos Diagnostics
node version     v0.10.28
operating sys    linux (ia32)

Searching for Sonos devices on network...

Device  {"host":"192.168.2.101","port":1400} (ZPS1)
`- attrs:   {"CurrentZoneName":"Play:1",
        "CurrentIcon":"x-rincon-roomicon:living",
        "CurrentConfiguration":"1"}
`- info:    {"SoftwareVersion":"27.2-80271",
        "DisplaySoftwareVersion":"5.1",
        "HardwareVersion":"1.8.3.7-2",
        "IPAddress":"192.168.2.101",
        "MACAddress":"XX:XX:XX:XX:XX:BA",
        "CopyrightInfo":"© 2004-2014 Sonos, Inc. All Rights Reserved.",
        "ExtraInfo":"OTP: ",
        "HTAudioIn":"0"}
`- topology:    [{"group":"RINCON_000E582D6D2C01400:1",
        "coordinator":"true",
        "wirelessmode":"0",
        "channelfreq":"2437",
        "behindwifiext":"0",
        "location":"http://192.168.2.102:1400/xml/device_description.xml",
        "version":"27.2-80271",
        "mincompatibleversion":"26.0-00000",
        "legacycompatibleversion":"24.0-0000",
        "bootseq":"95",
        "uuid":"RINCON_000E582D6D2C01400",
        "name":"Living Room"},{"group":"RINCON_B8E93753DABA01400:7",
        "coordinator":"true",
        "wirelessmode":"0",
        "channelfreq":"2437",
        "behindwifiext":"0",
        "location":"http://192.168.2.101:1400/xml/device_description.xml",
        "version":"27.2-80271",
        "mincompatibleversion":"26.0-00000",
        "legacycompatibleversion":"24.0-0000",
        "bootseq":"31",
        "uuid":"RINCON_B8E93753DABA01400",
        "name":"Play:1"}]

Device  {"host":"192.168.2.102","port":1400} (ZP90)
`- attrs:   {"CurrentZoneName":"Living Room",
        "CurrentIcon":"x-rincon-roomicon:living",
        "CurrentConfiguration":"1"}
`- info:    {"SoftwareVersion":"27.2-80271",
        "DisplaySoftwareVersion":"5.1",
        "HardwareVersion":"1.1.16.4-2",
        "IPAddress":"192.168.2.102",
        "MACAddress":"XX:XX:XX:XX:XX:2C",
        "CopyrightInfo":"© 2004-2014 Sonos, Inc. All Rights Reserved.",
        "ExtraInfo":"r8: 16.0-7",
        "HTAudioIn":"0"}
`- topology:    [{"group":"RINCON_B8E93753DABA01400:7",
        "coordinator":"true",
        "wirelessmode":"0",
        "channelfreq":"2437",
        "behindwifiext":"0",
        "location":"http://192.168.2.101:1400/xml/device_description.xml",
        "version":"27.2-80271",
        "mincompatibleversion":"26.0-00000",
        "legacycompatibleversion":"24.0-0000",
        "bootseq":"31",
        "uuid":"RINCON_B8E93753DABA01400",
        "name":"Play:1"},{"group":"RINCON_000E582D6D2C01400:1",
        "coordinator":"true",
        "wirelessmode":"0",
        "channelfreq":"2437",
        "behindwifiext":"0",
        "location":"http://192.168.2.102:1400/xml/device_description.xml",
        "version":"27.2-80271",
        "mincompatibleversion":"26.0-00000",
        "legacycompatibleversion":"24.0-0000",
        "bootseq":"95",
        "uuid":"RINCON_000E582D6D2C01400",
        "name":"Living Room"}]
stephen commented 9 years ago

Don't know when the issue started, but I'm getting the following error:

I think the Error: dns service error: unknown signals that there's a problem with avahi attempting to use mdns to broadcast that the device is available. Have you upgraded those packages recently?

One thing you might be able to try is doing a rebuild (or perhaps uninstalling/installing) if the bindings no longer match up.

dejongrr commented 9 years ago

Reinstall of the debian-chroot package did the trick!

Here is an update of the steps I took:

I used "airsonos &" to make sure airsonos keeps running after closing the terminal window. If someone knows how to set-up a proper start-stop script in debian chroot, please reply! My airsonos script path is: usr/local/bin/airsonos

dejongrr commented 9 years ago

@stephen - Does airsonos even have start and stop arguments? otherwise that would be a nice feature, in addition to a refresh or something.

pcr23 commented 9 years ago

First, I would like to say thanks to @stephen for airsonos and @dejongrr for the detailed instructions on how to install it. I wish I was knowledgeable enough to contribute something to this conversation.

Per @dejongrr instructions earlier in the conversation, airsonos was up and running on my synology until I closed terminal. Then a few days later I ran into the same "Error: dns service error: unknown" problem. So, I checked back every couple of days to see if there were any updates and sure enough, today I see new instructions. I uninstalled debian-chroot, restarted server, reinstalled debian-chroot, restarted server. Confirmed debian-chroot was running. Followed the rest of the steps to the letter. However, when I type the final step "airsonos" it says "/usr/bin/env: node: No such file or directory". I can see that it was installed. Any idea what I am doing wrong?

Thanks again.

stephen commented 9 years ago

@dejongrr - no, but adding support for library-like usage would make sense. Could open an issue or PR for it.

dejongrr commented 9 years ago

@pcr23 - I might have forgotten to add that to the instructions, but this should fix it:

pcr23 commented 9 years ago

Thank you very much for the help and the info, @dejongrr. Greatly appreciated.

pcr23 commented 9 years ago

Ok, everything is working great now. However, when I type "airsonos #" it still stops working when I close terminal. Do I type "airsonos #" as the last step.

BTW-thanks for taking the time to help me understand this. I'm learning slowly but surely.

RustyDust commented 9 years ago

I'm pretty sure that should read "airsonos &" instead of "aisonos #". the "&" tells your system to put the task in the background where it should keep running even when you close the terminal session.

-Stefan=

pcr23 commented 9 years ago

@RustyDust That did the trick. Thanks!

digiveit commented 9 years ago

Hello, first of all thank you for the great installation manual. It worked very well for me. I still have one problem: After I did the last update on my DS411+II and restarted it, I got hte following error message from airsonos: root@DiskStation:/# airsonos & [1] 337 root@DiskStation:/# * WARNING * The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs * WARNING * The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister Searching for Sonos devices on network... Setting up AirSonos for Wohnzimmer {192.168.0.36:1400}

Error: dns service error: unknown at new Advertisement (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns/lib/advertisement.js:56:10) at Object.create as createAdvertisement at NodeTunes. (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/server.js:74:21) at Server.g (events.js:180:16) at Server.emit (events.js:92:17) at net.js:1055:10 at process._tickCallback (node.js:419:13)

Any suggestions what I can do about it?

With thanks, Veit

karelmartens commented 9 years ago

Awesome guide, kudos to dejongrr and stephen!

I do experience the same issue as digiveit, I'm running DSM 5.1-5004 Update 2 on a DS212+

It worked fine after the install from dejongrr but after a reboot I did this from SSH:

root@....>/var/packages/debian-chroot/scripts/start-stop-status chroot root@.....:/# airsonos &

and I get this:

* WARNING * The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs * WARNING * The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister Searching for Sonos devices on network... Setting up AirSonos for Living Room {192.168.2.251:1400}

Error: dns service error: unknown at new Advertisement (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns/lib/advertisement.js:56:10) at Object.create as createAdvertisement at NodeTunes. (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/server.js:74:21) at Server.g (events.js:180:16) at Server.emit (events.js:92:17) at net.js:1055:10 at process._tickCallback (node.js:419:13)

Let me know if you want me to troubleshoot anything.

karelmartens commented 9 years ago

after some troubleshooting it might be coming from avahi-deamon: follow up on https://github.com/agnat/node_mdns/issues/43

root@...:/etc/avahi# service avahi-daemon status Avahi mDNS/DNS-SD Daemon is not running root@...:/etc/avahi# service avahi-daemon stop [ ok ] Stopping Avahi mDNS/DNS-SD Daemon: avahi-daemon. root@...:/etc/avahi# service avahi-daemon start [FAIL] Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon failed!

tried reinstalled avahi-deamon but no success

dejongrr commented 9 years ago

First of all, let me just state that I know very little of unix/debian etc. Since two months I own a Synology NAS and setting up the airsonos server was actually my first encounter with it. But, thanks to Stephen and Google, I managed to get it working...well...almost.

I have the same DNS issue as above and it is the same issue I had before. The solution was a total re-install of the debian package This will probably fix it, just like it did last time. At least now we know what the cause is; it is a Synology update that's breaking the avahi-daemon somehow. This feels a bit a-logical to me, since airsonos and all the dependant packages resided in the debian-chroot environment, which runs simultaneously (and independently, right?) with DSM. Can anyone shine a light on this?

jcplu commented 9 years ago

On SynoIogy DS213, the cpu (mine is Feroceon 88FR131) seems too slow (cpu usage is high) and the sound cuts. I can confirm that when the NAS reboots the avahi-daemon doesn't start anymore and AirSonos doesn't work too. You have to unsintall and reinstall avahi until avahi-daemon can start again (uninstallation of debian-chroot is not necessary).

On my netbook running Debian wheezy, AirSonos works well.

dejongrr commented 9 years ago

@jcplu: thanks for your response!

Based on your info, I tried to reinstall it, but that gave me another error regarding dbus. After googling around a bit I found a solution that worked. Just follow these steps:

I actually did not try to run airsonos right after de dbus restart, so maybe that already fixes it. Question is of course why the above is necessary in the first place..

jcplu commented 9 years ago

Sometimes the file /etc/default/avahi-daemon need to be fixed.

Change the line: AVAHI_DAEMON_DETECT_LOCAL=1 to AVAHI_DAEMON_DETECT_LOCAL=0

flexorflex commented 9 years ago

Hi! Everything work fine until: npm install airsonos -g Than I get this message: root@Server_DS:/# npm install airsonos -g Segmentation fault I've a DS214se running

ghost commented 9 years ago

What's the chances that we can get a real Synology package (that can be installed, updated etc. through Package Center)?

lottomotto commented 9 years ago

@dejongrr hello, thanks for all your work. I write you because it seems we had all the same problems. Solved the first ones reinstalleing everything following your guide from Nov 24 and now I am stuck at:

* WARNING * The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs * WARNING * The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister Searching for Sonos devices on network...

it actually doesn't find any of my Sonos

Tried your latest suggestion: type: /etc/init.d/dbus restart type: apt-get install --reinstall avahi-daemon

this is the result: root@DiskStation:/# /etc/init.d/dbus restart [ ok ] Stopping system message bus: dbus. [ ok ] Starting system message bus: dbus. root@DiskStation:/# apt-get install --reinstall avahi-daemon Reading package lists... Done Building dependency tree
Reading state information... Done 0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded. Need to get 0 B/97.6 kB of archives. After this operation, 0 B of additional disk space will be used. (Reading database ... 21114 files and directories currently installed.) Preparing to replace avahi-daemon 0.6.31-2 (using .../avahi-daemon_0.6.31-2_i386.deb) ... [ ok ] Stopping Avahi mDNS/DNS-SD Daemon: avahi-daemon. Unpacking replacement avahi-daemon ... Processing triggers for man-db ... Setting up avahi-daemon (0.6.31-2) ... [ ok ] Reloading system message bus config...done. [....] Starting Avahi mDNS/DNS-SD Daemon: avahi-daemonTimeout reached while wating for return value Could not receive return value from daemon process. (warning).

it doesn't start at all

I have a DS1513+ latest firmware.

Any idea of what could I try?

denkristoffer commented 9 years ago

Synocommunity actually offers a Node package, so it'd be obvious to take advantage of that. It should be possible to have a Synocommunity package developed for AirSonos if we can get some sort of start/stop command implemented.

LongChair commented 9 years ago

I would definitely second that :)

AirSonos seems the thing i have been looking for for a while, which retained me from buying a few Play1. But the only thing that would make sense to me would be to have it running on the only thing that's running 24/7, that is my syno nas, and even if that looks doable from the above, that doesnt look really straight forward :)

@stephen : any plans to get it to a synocommunity package ? :)

LongChair commented 9 years ago

I havetried a slightly different way to avoid the chroot and such, in order to see if something a bit more straight foward would be possible, here is what i did :

Grabbed the nodejs package from the package center (yes there is one)

capture d ecran 2015-01-18 a 11 23 12.

I also have iPkg installed on my Syno for this.

i found that as mentionned before you need python 2.7 do i had to type ipkg install python27

then i typed npm install airsonos -g but this fails on obviously using lame as shown in the log below. it's not very clear to me on what is failing yet ...

DiskStation> npm install airsonos -g
npm WARN deprecated static-favicon@1.0.2: use serve-favicon module

> mdns@2.2.2 install /usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns
> node-gyp rebuild

make: Entering directory `/volume1/@appstore/Node.js/usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns/build'
Makefile:1: /env.mak: No such file or directory
make: *** No rule to make target `/env.mak'.  Stop.
make: Leaving directory `/volume1/@appstore/Node.js/usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.2.40
gyp ERR! command "node" "/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /volume1/@appstore/Node.js/usr/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok 
/
> lame@1.1.2 install /usr/lib/node_modules/airsonos/node_modules/nicercast/node_modules/lame
> node-gyp rebuild

make: Entering directory `/volume1/@appstore/Node.js/usr/lib/node_modules/airsonos/node_modules/nicercast/node_modules/lame/build'
Makefile:1: /env.mak: No such file or directory
deps/mpg123/test.target.mk:116: warning: overriding recipe for target `Release/test'
deps/lame/test.target.mk:124: warning: ignoring old recipe for target `Release/test'
make: *** No rule to make target `/env.mak'.  Stop.
make: Leaving directory `/volume1/@appstore/Node.js/usr/lib/node_modules/airsonos/node_modules/nicercast/node_modules/lame/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.2.40
gyp ERR! command "node" "/volume1/@appstore/Node.js/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /volume1/@appstore/Node.js/usr/lib/node_modules/airsonos/node_modules/nicercast/node_modules/lame
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok 

npm ERR! mdns@2.2.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the mdns@2.2.2 install script.
npm ERR! This is most likely a problem with the mdns package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls mdns
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.2.40
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "airsonos" "-g"
npm ERR! cwd /root/airsonos
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

any clue anyone ?

dejongrr commented 9 years ago

A few months ago, I started trying getting Airsonos up and running with the node.js package (I also used the python package) as mentioned by @LongChair and encountered the same problems. Back then, I did some research and this is what I know:

Synology uses a lightweight Linux variant called Busybox, with Ash as the shell instead of something like the fully featured Bash. It also lacks a standard package manager like apt-get. In fact, there are no apt-get repositories for synology so apt-get is out of the question. Besides the Synology Package Center Gui, you'll have to do with ipkg as a manager to install compiled binaries. At first, you need to install ipkg via a script (bootstrap) that's processor specific. After that, all packages installed via ipkg will match your processor. Only problem is that the changes in the .config file in order to make ipkg work can be overwritten when synology firmware updates are installed.

Airsonos needs some dependancies like Node, libavahi-compat-libdnssd-dev and libasound2-dev. For installation, it uses node-gyp that is dependant of pacakges like make, gcc and python 2.7. And these are just the dependent packages I know...

Even after installing the packages Make and GCC via ipkg I got the same error as @LongChair has. This is why a tried to install airsonos in a closed environment with apt-get available (so no synology firmware updates mess up any setting, right?). There was a Debian Chroot package already available in the Synology package manger gui and within Debian you'll have access to apt-get. See my tutorial above.

Unfortunately, I know have the same issue as @lottomotto has... :( So no luck with debian as well.

The are some of the sites I consulted: http://en.wikipedia.org/wiki/BusyBox http://forum.synology.com/wiki/index.php/What_kind_of_CPU_does_my_NAS_have http://forum.synology.com/wiki/index.php/Overview_on_modifying_the_Synology_Server,_bootstrap,_ipkg_etc https://github.com/TooTallNate/node-gyp http://zarino.co.uk/post/custom-software-synology-dsm-update http://zarino.co.uk/post/ds214se-under-the-hood

dejongrr commented 9 years ago

Maybe this can help somebody to figure things out since it seems that shairport is simmular to airsonos in that it acts as an airplay receiver:

https://github.com/abrasive/shairport http://blog.elsdoerfer.name/2011/05/15/shairport-on-synology-nas/ http://www.losty.ch/2014/01/synology-nas-as-airplay-receiver.html https://github.com/SynoCommunity/spksrc/pull/848

LongChair commented 9 years ago

@dejongrr : i got the chroot method working to build it as well, but I haven't found a proper way to have it started when NAS is stating up.

Did anyone find a proper method for that ?

dejongrr commented 9 years ago

Sorry, I don't have a proper method for auto booting.

For those who are having avahi problems: I used a workaround shown on this site: https://github.com/lxc/lxc/issues/25 the trick is to remove 'rlimit-nproc=3' from /etc/avahi/avahi-daemon.conf

Type: vi /etc/avahi/avahi-daemon.conf use [h][j][k][l] as your cursus to go to the line 'rlimit-nproc=3', type: dd this will remove that line save and quit by typing: :wq now reinstall avahi by typing: apt-get install --reinstall avahi-daemon

It's working for me! I did a complete rebuild of debian and applied this workaround just before installing airsonos, but I think this should also work after installing.

HenkvdM commented 9 years ago

I've created the following startup script:

It is working for me on my Synology 415play. Give it a try. Thanks @dejongrr for you're install tutorial.

#!/bin/sh
#
# Put this file in /usr/local/etc/rc.d/airsonos.sh

case "$1" in

stop)
  echo "Stop AirSonos ..."
  chroot /usr/local/debian-chroot/var/chroottarget su - root -c "/etc/init.d/dbus stop"
  chroot /usr/local/debian-chroot/var/chroottarget su - root -c "/etc/init.d/avahi-daemon stop"
  pkill -f airsonos
;;

start)
  chroot /usr/local/debian-chroot/var/chroottarget su - root -c "/etc/init.d/dbus restart"
  chroot /usr/local/debian-chroot/var/chroottarget su - root -c "/etc/init.d/avahi-daemon start"
  nohup chroot /usr/local/debian-chroot/var/chroottarget su - root -c "/usr/local/bin/airsonos" >>/dev/null 2>>/dev/null &
;;

restart)
  $0 stop
  sleep 1
  $0 start
;;

status)
  ps | grep airsonos
  return $?
;;

*)
  echo "usage: $0 { start | stop | restart | status}" >&2
  exit 1
;;

esac
dejongrr commented 9 years ago

Thanks @HenkvdM for sharing your script! Somehow I'm fighting with vi (used it only to edit scripts) while creating the script. Could you provide all the necessary steps in order to create the script file?

Also, is there a reason you are not using init.d : https://www.debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian ? Seems like the more standard way of creating a start-stop script. Also, does is matter is doesn't have exit 0 at the end?

LongChair commented 9 years ago

i set it up following @dejongrr method with npm install airsonos -g and i have some wierd stuff on Syno.

First of all if i run airsonos from my mac, it jusr works and is detecting my 4 sonos devices ( 2 x Play 1 , 1 x Play 5 and one Sonos BOOST).

But when running it from the Syno it randomly detects one of the 4 devices and outputs the following logs :

root@DiskStation:/# airsonos &
[1] 6353
root@DiskStation:/# *** WARNING *** The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs>
*** WARNING *** The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister>
Searching for Sonos devices on network...
Setting up AirSonos for BOOST {192.168.1.240:1400}

Error: dns service error: unknown
    at new Advertisement (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns/lib/advertisement.js:56:10)
    at Object.create [as createAdvertisement] (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/node_modules/mdns/lib/advertisement.js:64:10)
    at NodeTunes.<anonymous> (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/server.js:74:21)
    at Server.g (events.js:180:16)
    at Server.emit (events.js:92:17)
    at net.js:1055:10
    at process._tickCallback (node.js:419:13)

Any ideas ?

dejongrr commented 9 years ago

@longchair Check one of my recent posts above, the trick is to remove 'rlimit-nproc=3' from /etc/avahi/avahi-daemon.conf

HenkvdM commented 9 years ago

On Synology is /usr/local/etc/rc.d/ the place where you place your startup script. The script runs fine without exit 0.

dejongrr commented 9 years ago

Thanks @HenkvdM . I was under the presumption that the script needed to be installed within the debian choort environment. But after looking more closely at the script, I saw that it runs from the synology root itself. And it works! Awesome!

HenkvdM commented 9 years ago

At first I also thought it needed to run in the chroot environment But I found out you can run it from the Synology command line, that made it a lot simpler. Glad I could help.