Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Cannot send system audio to P:1 #17

Closed
wooly opened this issue May 1, 2014 · 11 comments
Closed

Cannot send system audio to P:1 #17

wooly opened this issue May 1, 2014 · 11 comments
Labels

Comments

@wooly
Copy link
Contributor

wooly commented May 1, 2014

I'm getting an Error: listen EADDRINUSE with the system audio set to stream to the airplay. Here's what I'm doing:

• Start airsonos, which successfully finds my P:1
• Open Sound settings in sysprefs and select AirSonos output device
• Mash the volume keys on my mac up and down
• No clicking sound is heard through sonos, which crashes with the following shortly after:

➜  airsonos git:(master) airsonos
Searching for Sonos devices on network...
Setting up AirSonos for Master Bedroom {192.168.0.7:1400}

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EADDRINUSE
    at errnoException (net.js:883:11)
    at Server._listen2 (net.js:1021:14)
    at listen (net.js:1043:10)
    at Server.listen (net.js:1109:5)
    at Function.app.listen (/usr/local/share/npm/lib/node_modules/airsonos/node_modules/nicercast/node_modules/express/lib/application.js:533:24)
    at Server.start (/usr/local/share/npm/lib/node_modules/airsonos/node_modules/nicercast/index.js:104:9)
    at /usr/local/share/npm/lib/node_modules/airsonos/lib/main.js:57:25
    at /usr/local/share/npm/lib/node_modules/airsonos/node_modules/portastic/lib/portastic.coffee:31:22
    at /usr/local/share/npm/lib/node_modules/airsonos/node_modules/portastic/node_modules/async/lib/async.js:236:13
    at /usr/local/share/npm/lib/node_modules/airsonos/node_modules/portastic/node_modules/async/lib/async.js:116:25

Any ideas?

@stephen
Copy link
Owner

stephen commented May 1, 2014

Hmm, can you see which port airsonos is trying to use (add console.log(port) at line 57 of /lib/main.js), and if you have something else on your system running on that port?

When finding a port, it should compensate for ports being used via portastic..

@wooly
Copy link
Contributor Author

wooly commented May 1, 2014

So I've added console.log('Client connected'); as the first line of the 'clientConnected' event callback function, and I'm logging the port in the portastic callback. Unfortunately, the client connected log line is never called. I would expect this to happen when I select the airplay as the output device in sysprefs, is this right?

I just get...

➜  airsonos git:(master) ✗ node index.js
Searching for Sonos devices on network...
Setting up AirSonos for Master Bedroom {192.168.0.7:1400}

but no 'Client connected'

@stephen
Copy link
Owner

stephen commented May 1, 2014

Yes, those console.log lines should happen... EADDRINUSE is happening after you attempt to connect, correct? (I can't see a way that the error on line 57 would happen without log commands before it happening...)

Are you modifying a local copy (vs. the -g globally installed) version?

@wooly
Copy link
Contributor Author

wooly commented May 1, 2014

Modifying the local copy yep, here's what I see
screen shot 2014-05-01 at 21 38 40

My local copy:

      console.log('Setting up AirSonos for', deviceName, '{' + device.host + ':' + device.port + '}');
      console.log('Beans on toast');

      var airplayServer = new NodeTunes({
        serverName: 'AirSonos @ ' + deviceName
      });

      airplayServer.on('clientConnected', function(audioStream) {
        console.log('Client connected');

So it never logs the 'Client connected' message, even after I select the airplay device in the sysprefs.

@stephen
Copy link
Owner

stephen commented May 1, 2014

Are you actively playing sound? AirPlay doesn't actually attempt to connect until there's audio being played on the device.

When does the error you're seeing actually happen?

@wooly
Copy link
Contributor Author

wooly commented May 1, 2014

Ah ok! I thought it would connect as soon as I set it to be the active device. So after that, I start to hit volume up, and it continuously logs client connected and an incrementing port number until it gets to 8050, then crashes...

Client connected
8046
Client connected
8047
Client connected
8048
Client connected
8049
Client connected
8050
Client connected
undefined

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EADDRINUSE
    at errnoException (net.js:883:11)
    at Server._listen2 (net.js:1021:14)
    at listen (net.js:1043:10)
    at Server.listen (net.js:1109:5)
    at Function.app.listen (/Users/steve/version-control/airsonos/node_modules/nicercast/node_modules/express/lib/application.js:533:24)
    at Server.start (/Users/steve/version-control/airsonos/node_modules/nicercast/index.js:104:9)
    at /Users/steve/version-control/airsonos/lib/main.js:60:25
    at /Users/steve/version-control/airsonos/node_modules/portastic/lib/portastic.coffee:31:22
    at /Users/steve/version-control/airsonos/node_modules/portastic/node_modules/async/lib/async.js:236:13
    at /Users/steve/version-control/airsonos/node_modules/portastic/node_modules/async/lib/async.js:116:25

@stephen
Copy link
Owner

stephen commented May 1, 2014

Interesting.. Do you have anything running on those ports? (Try a netstat -p)?

@wooly
Copy link
Contributor Author

wooly commented May 2, 2014

Nothing running on 8051. If I update the max portastic port to 8060, it'll go to 8060 before throwing the same error.

Also, the clicking sounds that you get when you change the volume don't come out of the P:1 when this is happening, both it and my mac are completely silent.

@stephen
Copy link
Owner

stephen commented May 2, 2014

Odd. Can you try running portastic's example and see if that works? (https://github.com/cranic/node-portastic) Seems like an issue with portastic at this point..

Makes sees that the volume change click isn't happening (in the context of the error you're seeing) - what's happening is that the server the Sonos speaker attempts to connect to for audio isn't being started because it's not able to connect to any port 8000-8050.

@wooly
Copy link
Contributor Author

wooly commented May 2, 2014

I'm not sure it's a portastic issue, more to do with the client connecting every time I hit volume up. If I set the airsonos as my output device for audio, open VLC and open a video file, I get audio playing after a few seconds.

Is it possible to make airsonos reuse the same port for streaming each time I hit volume up, rather than creating a new icecastServer instance every time and starting it on another port?

@stephen
Copy link
Owner

stephen commented May 3, 2014

I don't think the volume change is directly coupled with AirSonos attempting to re-connect. (Although it might be indirectly, when the "click" noise attempts to play, OS X attempts to connect to AirSonos to pipe the audio (which fails each time, thereby having OS X try again the next time you hit volume change, etc. etc.)).

Does this only happen when you press on volume up/down? (i.e. play audio on vlc, don't touch volume does it work fine until you change volume?)

Can you also try a different port range? e.g. something in the 50000's range?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants