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

upnp.stopDiscovery() not called #1

Closed svencan closed 8 years ago

svencan commented 8 years ago

I have a Cordova project with JXCore using this node module.

UPNP discovery basically works, I listen for devices and I can start the discovery. However, stopDiscovery() doesn't seem to work. After starting the discovery, I set a timeout like so:

setTimeout(function() {
    Mobile('debug').call('Attempt to stop discovery');
    upnp.stopDiscovery(function() {
        Mobile('debug').call('Discovery stopped');
        callback({info: 'Stopped scanning'});
        process.exit();
    });
}, seconds * 1000);

Mobile('debug').call('Attempt to stop discovery'); eventually prints the string to the console, so the timeout works. But the callback given to upnp.stopDiscovery() is not executed. Furthermore I can't start the process again without completely restarting the app.

Any idea how to fix this?

Edit: I narrowed it down a bit. In node-upnp-utils.js in the stopDiscovery function, none of the callbacks given to this.sockets[...].close() are executed. For the moment I cannot debug it further than that.

futomi commented 8 years ago

Thanks for your feedback.

I examined the issue using JXcore. https://github.com/jxcore/jxcore-release

I found that JXcore is based on Node.js 0.10.40 which is too old to use the node-upnp-utils.

> process.versions;
{ http_parser: '1.0',
  node: '0.10.40',
  jxcore: '0.3.1.1',
  ch: 0,
  v8: '3.14.5.9',
  sm: 0,
  embedded: { sqlite: '3.9.1' },
  ares: '1.9.0-DEV',
  uv: '0.10.36',
  zlib: '1.2.3',
  modules: '11',
  openssl: '1.0.1p' }
>

The node-upnp-utils was developed for Node.js 4+. JXcore based on Node.js 0.10 does not support the arrow function syntax (i.e. (param1, param2, …, paramN) => { statements }) specified in ECMAScript 2015.

I'm afraid that I'm not planning to support older versions of Node than 4. Sorry.