UPnP discovery, description inside Javascript

I am looking to get UPnP device discovery, description done in Javascript - either in standalone browser environment or in NodeJS Towards that, I tried below two solutions but both did not work for me. Details -

1]NodeJS bases: https://www.npmjs.com/package/upnp-client After correcting few typos in the example app, and running it in node (My nodeJS is running under X-Ubuntu Virtual Machine inside Virtualbox) I get below errors on running the upnp-client example app

dgram.js:399 throw new errnoException(process._errno, 'addMembership'); ^ Error: addMembership EBADF at new errnoException (dgram.js:457:11)

NodeJS version: v0.10.25 Upnp client api: 0.0.1

2]Under Browser(Chrome/IE) https://www.npmjs.com/package/upnp-client None of them at the versions I have supported the navigator.getNetworkServices API which seems to be needed for this library

How can i get UPnP device discovery working in Javascript?

Any other solutions or pointers to resolve above errors/workarounds appreciated.


UPnP uses TCP/UDP packages for advertisement/discovery/etc. And since browsers cannot open network sockets, the short answer is: No. We can't use UPnP in a browser at the moment.

The only glimmer of hope is the Network Service Discovery, which is still in development phase in most of the browsers. In Chrome for example you could enable it using chrome://flags/#enable-experimental-web-platform-features, and then would be able to do something like this (from W3C draft):

function showServices( services ) {
  // Show a list of all the services provided to the web page
  for(var i = 0, l = services.length; i < l; i++) console.log( services[i].name );
}

navigator.getNetworkServices('zeroconf:_boxee-jsonrpc._tcp').then(showServices);