futomi / node-upnp-utils

The node-upnp-utils allows you to discover UPnP devices or services in the same subnet and to invole actions or queries to the targeted device.
MIT License
16 stars 3 forks source link

Then occur error `connect ECONNREFUSED', force close. #2

Open youkinjoh opened 8 years ago

youkinjoh commented 8 years ago

I use this module in sample code. I often happen connect ECONNREFUSED error and force close. Sorry, I don't know condition and method for error.

(Sorry, IP address and port number masked...

% nvm ls | grep current
current:    v6.3.1
% node index.js
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 10.XXX.YYY.ZZZ:PPPP
    at Object.exports._errnoException (util.js:1012:11)
    at exports._exceptionWithHostPort (util.js:1035:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
exit 1
var upnp = require('node-upnp-utils');

// Set an event listener for 'added' event
upnp.on('added', (device) => {
  // This callback function will be called whenever an device is found.
  console.log(device['address']);
  console.log(device['description']['device']['friendlyName']);
  console.log(device['headers']['LOCATION']);
  console.log(device['headers']['USN']);
  console.log('------------------------------------');
});

// Start the discovery process
upnp.startDiscovery();
futomi commented 7 years ago

Thank you for your feedback. I tried same sample code. As you let me know, the same error was occurred. I don't know the reason why the error is occurred now. The error was not occurred before. I'll investigate the reason. Give me some time.

damiles commented 7 years ago

I have simillar issue:

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: bind EADDRINUSE 0.0.0.0:1900
    at Object.exports._errnoException (util.js:870:11)
    at exports._exceptionWithHostPort (util.js:893:20)
    at dgram.js:213:18
    at nextTickCallbackWith3Args (node.js:452:9)
    at process._tickCallback (node.js:358:17)
    at Function.Module.runMain (module.js:444:11)
    at startup (node.js:136:18)
    at node.js:966:3
damiles commented 7 years ago

Anyway you can catch the error with

upnp.on('error', (err) => {
    console.dir(err);
});