Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multiple listeners from same host #518

Open
GerritKuilder opened this issue Sep 27, 2021 · 5 comments
Open

Use multiple listeners from same host #518

GerritKuilder opened this issue Sep 27, 2021 · 5 comments

Comments

@GerritKuilder
Copy link

Don't know if this is related to Sonos or the code

Expected Behavior

Have an app running on 192.168.12.100
this app listens on sonos events and does what it is expected to do.

Create another app srunning on the same host and try to listen to the sonos device

Start the listener so you can respond to events

Current Behavior

when the second app is started the following error is generated:
Listen for sonos events. CTRL + C to exit
node:events:371
throw er; // Unhandled 'error' event
^

Error: listen EADDRINUSE: address already in use :::4000
at Server.setupListenHandle [as _listen2] (node:net:1319:16)
at listenInCluster (node:net:1367:12)
at Server.listen (node:net:1454:7)
at SonosListener.startListener (/home/gerrit/workspace/code/dev/betterspotv2/node_modules/sonos/lib/events/adv-listener.js:67:25)

Possible Solution

Sample code or executed example

  1. use script: https://github.com/bencevans/node-sonos/blob/master/examples/events.js
  2. (replace '../' with 'sonos'
    4.have one sonos listener already running
    5 run script
    6 error message

Versions (and Environment)

Node version:
latest
node-sonos version:
latest
OS:
UBUNTU

@svrooij
Copy link
Collaborator

svrooij commented Sep 29, 2021

@GerritKuilder I must admit that this isn't documented anywhere, but you can set the environment variable SONOS_LISTENER_PORT to change the port that is used for the listener.

My I ask what the use case is for running multiple apps listening for events on the same host?

this.port = parseInt(process.env.SONOS_LISTENER_PORT || 4000)

@GerritKuilder
Copy link
Author

Hi,

I have a dev version and a prod version running on the same server....
Will try and check later today.
Kind regards,

Gerrit Kuilder

@GerritKuilder
Copy link
Author

Yes, that works perfectly, thanks

@svrooij
Copy link
Collaborator

svrooij commented Sep 30, 2021

Do you have an idea where this should be documented?

@GerritKuilder
Copy link
Author

I think you should add a note to the example?

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

No branches or pull requests

2 participants