dpjanes / iotdb-upnp

Universal Plug & Play Library - for IOTDB and Stand Alone
Apache License 2.0
0 stars 0 forks source link

EADDRINUSE when another upnp is on the same machine #1

Closed neversay closed 9 years ago

neversay commented 9 years ago

I erased my SD card and installed the LMS ( Logitech Media Server UPnP/DLNA Plugin ) to control my music and play it on different raspberry PIs in my house, I reinstall homestar and found that the LMS might occupied the same port that iotdb wants to use:

{"name":"iotdb-upnp","module":"upnp","hostname":"anna","pid":28950,"level":30,"method":"cp","msg":"made UpnpControlPoint","time":"2015-03-07T19:59:30.597Z","v":0} Error: bind EADDRINUSE at exports._errnoException (util.js:746:11) at dgram.js:224:28 at dns.js:85:18 at process._tickDomainCallback (node.js:381:11) {"name":"iotdb-upnp","module":"upnp/upnp-device","hostname":"anna","pid":28950,"level":30,"method":"UpnpDevice","uuid":"0172e150-cd03-9a38-bb0b-3683792829a5","msg":"new device object","time":"2015-03-07T19:59:31.060Z","v":0} {"name":"iotdb-upnp","module":"upnp/upnp-device","hostname":"anna","pid":28950,"level":30,"method":"UpnpDevice","device":{"loction":"http://192.168.0.1:1900/WFADevice.xml","uuid":"0172e150-cd03-9a38-bb0b-3683792829a5","deviceType":"urn:schemas-wifialliance-org:device:WFADevice:1","friendlyName":"WFADevice","manufacturer":"Broadcom Corporation","modelNumber":"X1","modelDescription":"Wireless Device","modelName":"WPS"},"msg":"previously unseen UPnP device","time":"2015-03-07T19:59:31.076Z","v":0} {"name":"iotdb-upnp","module":"upnp/upnp-device","hostname":"anna","pid":28950,"level":30,"method":"UpnpDevice","uuid":"07365A05-F74E-4A31-931B-E41DCA09F666","msg":"new device object","time":"2015-03-07T19:59:31.477Z","v":0} {"name":"iotdb-upnp","module":"upnp/upnp-device","hostname":"anna","pid":28950,"level":30,"method":"UpnpDevice","device":{"loction":"http://192.168.0.2:9000/plugins/UPnP/MediaServer.xml","uuid":"07365A05-F74E-4A31-931B-E41DCA09F666","deviceType":"urn:schemas-upnp-org:device:MediaServer:1","friendlyName":"Logitech Media Server [anna]","manufacturer":"Logitech","modelNumber":"1","modelDescription":"Logitech Media Server UPnP/DLNA Plugin","modelName":"Logitech Media Server 7.8.01395409907"},"msg":"previously unseen UPnP device","time":"2015-03-07T19:59:31.496Z","v":0} {"name":"iotdb-upnp","module":"upnp/upnp-device","hostname":"anna","pid":28950,"level":30,"method":"UpnpDevice","uuid":"D075241A-59FA-69EC-DE94-82AFAC267E19","msg":"new device object","time":"2015-03-07T19:59:32.145Z","v":0} {"name":"iotdb-upnp","module":"upnp/upnp-device","hostname":"anna","pid":28950,"level":30,"method":"UpnpDevice","device":{"loction":"http://192.168.0.2:9000/plugins/UPnP/MediaRenderer.xml?player=e0%3A91%3A53%3A69%3Ac8%3Abe","uuid":"D075241A-59FA-69EC-DE94-82AFAC267E19","deviceType":"urn:schemas-upnp-org:device:MediaRenderer:1","friendlyName":"anna","manufacturer":"Logitech","modelNumber":"1","modelDescription":"Logitech Media Server UPnP/DLNA Plugin","modelName":"Squeezebox"},"msg":"previously unseen UPnP device","time":"2015-03-07T19:59:32.150Z","v":0}

So the homestar runner stop working since I reinstall it :( .

dpjanes commented 9 years ago

Sorry, I see the error EADDRINUSE - but what stops working? Homestar runner won't come up at all?

Also see changing the port here: https://github.com/dpjanes/iotdb-homestar/blob/master/docs/configure.md

neversay commented 9 years ago

Yap, I set the port at 4444, but it still crashed once I ran homestar runner: https://gist.github.com/neversay/a5cc75492d257793523c

neversay commented 9 years ago

Those are the ports used by my suspect ports (used by Apache, SqueezeBox, SqueezeLite and Shairport): Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:9090 0.0.0.0:* LISTEN 22650/perl
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 22650/perl
tcp 0 0 0.0.0.0:5002 0.0.0.0:* LISTEN 16060/shairport tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2269/apache2
tcp 0 0 0.0.0.0:3483 0.0.0.0:* LISTEN 22650/perl
tcp 0 0 0.0.0.0:40190 0.0.0.0:* LISTEN 22650/perl
udp 0 0 0.0.0.0:3483 0.0.0.0:* 22650/perl
udp 0 0 0.0.0.0:49727 0.0.0.0:* 22650/perl
udp 0 0 0.0.0.0:5353 0.0.0.0:* 9445/avahi-daemon: udp 0 0 0.0.0.0:43287 0.0.0.0:* 9445/avahi-daemon: udp 0 0 0.0.0.0:1900 0.0.0.0:* 22650/perl
udp 0 0 192.168.0.2:1900 0.0.0.0:* 22650/perl

dpjanes commented 9 years ago

Hmmm. When I play around a bit I can recreate something similar by running homestar up twice. The error may be the websocket. Try this:

Try:

homestar runner webserver/port=12345 mqttd/websocket=12346 mqttd/port=123457

On Sat, Mar 7, 2015 at 11:40 PM, Neversay notifications@github.com wrote:

Those are the ports used by my suspect ports (used by Apache, SqueezeBox, SqueezeLite and Shairport): Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:9090 0.0.0.0:* LISTEN 22650/perl

tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 22650/perl

tcp 0 0 0.0.0.0:5002 0.0.0.0:* LISTEN 16060/shairport tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2269/apache2

tcp 0 0 0.0.0.0:3483 0.0.0.0:* LISTEN 22650/perl

tcp 0 0 0.0.0.0:40190 0.0.0.0:* LISTEN 22650/perl

udp 0 0 0.0.0.0:3483 0.0.0.0:* 22650/perl

udp 0 0 0.0.0.0:49727 0.0.0.0:* 22650/perl

udp 0 0 0.0.0.0:5353 0.0.0.0:* 9445/avahi-daemon: udp 0 0 0.0.0.0:43287 0.0.0.0:* 9445/avahi-daemon: udp 0 0 0.0.0.0:1900 0.0.0.0:* 22650/perl

udp 0 0 192.168.0.2:1900 0.0.0.0:* 22650/perl

— Reply to this email directly or view it on GitHub https://github.com/dpjanes/iotdb-upnp/issues/1#issuecomment-77732886.

neversay commented 9 years ago

I guess you can reproduce it by a script that turn on multiple http server and occupied the ports I listed above. And for the command I still got the same exception:

homestar runner webserver/port=12345 mqttd/websocket=12346 mqttd/port=12347

...... {"name":"iotdb","module":"things","hostname":"anna","pid":19664,"level":30,"method":"_discover_binding","modeld":{},"binding":{"matchd":{"iot:vendor/type":"urn:Belkin:device:lightswitch:1"},"connectd":{"subscribes":["urn:Belkin:service:basicevent:1"]},"model_code":"we-mo-light-switch"},"msg":"called","time":"2015-03-08T18:16:27.220Z","v":0} {"name":"iotdb-upnp","module":"upnp","hostname":"anna","pid":19664,"level":30,"method":"cp","msg":"made UpnpControlPoint","time":"2015-03-08T18:16:27.256Z","v":0} {"name":"iotdb","module":"IOT","hostname":"anna","pid":19664,"level":30,"method":"_exit_cleanup","paramd":{"from":"exit"},"err":1,"msg":"start","time":"2015-03-08T18:16:27.320Z","v":0} {"name":"iotdb","module":"IOT","hostname":"anna","pid":19664,"level":30,"method":"_exit_cleanup","paramd":{"from":"exit"},"err":1,"msg":"start","time":"2015-03-08T18:16:27.326Z","v":0} events.js:85 throw er; // Unhandled 'error' event ^ Error: bind EADDRINUSE at exports._errnoException (util.js:746:11) at dgram.js:224:28 at dns.js:85:18 at process._tickCallback (node.js:355:11) at Function.Module.runMain (module.js:503:11) at startup (node.js:129:16) at node.js:814:3

dpjanes commented 9 years ago

Do you have any insight / thoughts / guesses? I'm a bit of a loss right now.

D.

On Sun, Mar 8, 2015 at 2:19 PM, Neversay notifications@github.com wrote:

I guess you can reproduce it by a script that turn on multiple http server and occupied the ports I listed above. And for the command I still got the same exception:

homestar runner webserver/port=12345 mqttd/websocket=12346 mqttd/port=12347

......

{"name":"iotdb","module":"things","hostname":"anna","pid":19664,"level":30,"method":"_discover_binding","modeld":{},"binding":{"matchd":{"iot:vendor/type":"urn:Belkin:device:lightswitch:1"},"connectd":{"subscribes":["urn:Belkin:service:basicevent:1"]},"model_code":"we-mo-light-switch"},"msg":"called","time":"2015-03-08T18:16:27.220Z","v":0} {"name":"iotdb-upnp","module":"upnp","hostname":"anna","pid":19664,"level":30,"method":"cp","msg":"made UpnpControlPoint","time":"2015-03-08T18:16:27.256Z","v":0}

{"name":"iotdb","module":"IOT","hostname":"anna","pid":19664,"level":30,"method":"_exit_cleanup","paramd":{"from":"exit"},"err":1,"msg":"start","time":"2015-03-08T18:16:27.320Z","v":0}

{"name":"iotdb","module":"IOT","hostname":"anna","pid":19664,"level":30,"method":"_exit_cleanup","paramd":{"from":"exit"},"err":1,"msg":"start","time":"2015-03-08T18:16:27.326Z","v":0} events.js:85 throw er; // Unhandled 'error' event ^ Error: bind EADDRINUSE at exports._errnoException (util.js:746:11) at dgram.js:224:28 at dns.js:85:18 at process._tickCallback (node.js:355:11) at Function.Module.runMain (module.js:503:11) at startup (node.js:129:16) at node.js:814:3

— Reply to this email directly or view it on GitHub https://github.com/dpjanes/iotdb-upnp/issues/1#issuecomment-77765559.

neversay commented 9 years ago

I tried to stop all my network services and ran homestar again with "webserver/port=12345 mqttd/websocket=12346 mqttd/port=12347" , it worked. And then I scanned the ports again and found that the homestar still tried to open socket at port 1900: Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:39895 0.0.0.0:* LISTEN 8561/node
tcp 0 0 192.168.0.2:12345 0.0.0.0:* LISTEN 8561/node
tcp 0 0 0.0.0.0:12346 0.0.0.0:* LISTEN 8561/node
tcp 0 0 192.168.0.2:12347 0.0.0.0:* LISTEN 8561/node
udp 0 0 0.0.0.0:1900 0.0.0.0:* 8561/node

which means something in the upnp service port did not got overwritten by 12346 or 12347 we assigned.

neversay commented 9 years ago

According to https://www.grc.com/port_1900.htm , the port 1900 with udp is used by SSDP. I dont know if a UPnP with SSDP can pick up another port. If not, then it means we cannot start 2 different UPnP services at the same machine. :(

dpjanes commented 9 years ago

It might be changeable! Unfortunately (sorta), I'm in a place with no UPnP devices right now for the next two weeks. If you look for node_modules/iotdb-upnp/upnp/upnp.js look for SSDP_PORT. It seems to be "soft" everywhere it is used.

If you can confirm that it will work if changed, I'll see if I can make it a soft variable.

D.

On Mon, Mar 9, 2015 at 1:08 AM, Neversay notifications@github.com wrote:

According to https://www.grc.com/port_1900.htm , the port 1900 with udp is used by SSDP. I dont know if a UPnP with SSDP can pick up another port. If not, then it means we cannot start 2 different UPnP services at the same machine. :(

— Reply to this email directly or view it on GitHub https://github.com/dpjanes/iotdb-upnp/issues/1#issuecomment-77801021.

neversay commented 9 years ago

Yap I changed the value to 9999 and the runner start to run, but detect nothing: https://gist.github.com/neversay/0f4c208e73b56e28112b

I think the SSDP failed to broadcast in port 9999, or the UPnP devices still try to response the message with 1900 port. But at least the runner start to work.

dpjanes commented 9 years ago

K thanks. I'll look at this when I get off the beach (i.e. 10 days or so) and see if I can:

in order of preference

On Tue, Mar 10, 2015 at 2:48 AM, Neversay notifications@github.com wrote:

Yap I changed the value to 9999 and the runner start to run, but detect nothing: https://gist.github.com/neversay/0f4c208e73b56e28112b

I think the SSDP failed to broadcast in port 9999, or the UPnP devices still try to response the message with 1900 port. But at least the runner start to work.

— Reply to this email directly or view it on GitHub https://github.com/dpjanes/iotdb-upnp/issues/1#issuecomment-78003874.

dpjanes commented 9 years ago

The spec more or less says 1900 has to be it http://www.upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0-20080424.pdf

I may be able to force it to share the port tho so all home is not lost.

dpjanes commented 9 years ago

I think I got it! There's a new option in dgram.createSocket that allows multiple UDP listeners. Please try and let me know. Note that I'm testing against Node 0.12 now (I was Node 0.10). It will probably work with Node 0.11

dpjanes commented 9 years ago

Any luck? Would like to close this one out.

neversay commented 9 years ago

No chance to test it yet. will try it tonight......

neversay commented 9 years ago

Yap It Works!!! So magic! Though It only works when I run "homestar runner" and controlled by webpage interface. But still amazing!