diversario / node-ssdp

node.js SSDP client/server.
MIT License
273 stars 120 forks source link

Why no notify event for the client? #78

Open cinhcet opened 7 years ago

cinhcet commented 7 years ago

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!

brannondorsey commented 6 years ago

+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.

mroch commented 5 years ago

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.

simonbowen commented 3 years ago

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.

troppoli commented 3 years ago

I gave up and moved to dnssd2 it works.