Getting AirSonos Working

AirSonos is a node based implementation of the AirPlay protocol which allows you to wirelessly stream any audio from an iOS device to your Sonos speakers. Why does this matter?

I listen to a lot of podcasts on my iPhone using Overcast & really love the Smart Speed & Voice Boost features. AirSonos allows me to stream from the app to my Sonos system and still use the features. The speakers appear as any Airplay speaker would in the pop-up menu at the bottom.

Whilst setting this up I had 2 main issues which seem to be common for lots of other users. After spending a few hours on forums to fix the issues, I thought it may be helpful to document the fixes in this short article.

Issue One

Once AirSonos is installed, it won’t run. You see an error that looks like this:

$ airsonos
Searching for Sonos devices on network...

throw e;
Error: Internal Server Error
at maybeWrapAsError (/usr/local/lib/node_modules/airsonos/node_modules/bluebird/js/main/util.js:70:12)
at /usr/local/lib/node_modules/airsonos/node_modules/bluebird/js/main/promise_resolver.js:41:50
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/logicalDevice.js:112:20
at done (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:126:15)
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:32:16
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/logicalDevice.js:106:22
at done (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:126:15)
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:32:16
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:251:17
at done (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:126:15)
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:32:16
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:248:21
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/async/lib/async.js:572:34
at /usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/events/volumeListener.js:24:14
at Listener. (/usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/events/listener.js:123:9)
at Request.self.callback (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/request/request.js:129:22)

This issue appears to be caused by how your  Sonos network is setup. If you are using a Bridge, the speakers are communicating on a private network separate to your normal Wi-fi network. AirSonos is looking for the speakers on the same network it is running on, but they are are not there.

Try removing your Bridge as it is not needed anymore. In a recent software update, Sonos now made it possible that you can run the system on your existing Wi-fi network.

Following the setup guide on the Sonos website, try setting up your system without the Bridge. Now try running AirSonos again and it should work. You should see a list of all your speakers which will show up in all your Airplay enabled apps.

Issue Two

When AirSonos is running, selecting a speaker to stream too won’t do anything & AirSonos will crash. The error will look something like this:

Error: Invalid key length
at Error (native)
at new Decipheriv (crypto.js:232:16)
at Object.Decipheriv (crypto.js:229:12)
at Object.decryptAudioData (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/helper.js:141:25)
at RtpServer. (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/rtp.js:32:23)
at emitTwo (events.js:106:13)
at Socket.emit (events.js:191:7)
at UDP.onMessage (dgram.js:540:8)

This is caused by an issue in the nodetunes package which has been fixed (see the PR here), but not merged into the codebase yet. If you want to apply the fix yourself open up this file:


On around line 141 replace this line:

var decipher = crypto.createDecipheriv('aes-128-cbc', audioAesKey, audioAesIv);

With these 2 lines:

var audioAesKeyBuffer = new Buffer(audioAesKey, 'binary');
var decipher = crypto.createDecipheriv('aes-128-cbc', audioAesKeyBuffer, audioAesIv);

Now start AirSonos & try to play something to one of your Sonos speakers again. It should now be working.


I hope you found this quick article helpful – please share it if you did.