node-ssdp icon indicating copy to clipboard operation
node-ssdp copied to clipboard

Why no notify event for the client?

Open cinhcet opened this issue 7 years ago • 4 comments

Hi,

in my understanding (maybe I'm wrong) of the UPnP specifications, a client, which is the control point, should be able to listen to ssdp:alive, ssdp:byebye and ssdp:update notifications from devices. In the /example/client.js there is such a "notify" event, which is, however, never be emitted? Looking at the code, in the method SSDP.prototype._notify such events are handled. So why does the following not work?

var SSDP = require('node-ssdp').Client;
var client = new SSDP();

client.on('advertise-alive', function (headers, rinfo) {
  console.log(headers);
  console.log(rinfo);
});

client.on('advertise-bye', function (headers, rinfo) {
  console.log(headers);
  console.log(rinfo);
});

Thanks!

cinhcet avatar Apr 17 '17 13:04 cinhcet

+1, this doesn't appear to be working correctly. I also can't get the 'notify' event to fire (I'm monitoring with Wireshark and can confirm /NOTIFY multicast messages are being broadcast). The only event I've been able to get to fire is response.

Is it possible to view notifications and alive advertisements without explicitly calling client.search(...)? So far, the only SSDP messages I've been able to receive from the client are ones that I've explicitly triggered with an M-SEARCH request. I am interested in passively listening to service advertisements.

brannondorsey avatar Apr 11 '18 04:04 brannondorsey

see my comment here: https://github.com/diversario/node-ssdp/issues/95#issuecomment-478291570

the client doesn't wait for responses before exiting. you can do something like var timeout = setTimeout(function() {}, 1000000) and clearTimeout(timeout) when you're ready to exit. or remove the socket.unref() in SSDP.prototype._createSockets, but I don't know what other ramifications that has.

mroch avatar Mar 30 '19 21:03 mroch

Did you ever get this working?

I am also trying to get the notify (or advertise-bye, advertise-live) event firing on the client. I've added a timeout at the end of script to keep it alive for testing purposes but cannot get the events fired at all. M-SEARCH works fine.

simonbowen avatar Jan 19 '21 16:01 simonbowen

I gave up and moved to dnssd2 it works.

troppoli avatar Jan 19 '21 17:01 troppoli