SSDP server does not respond to mutlicast M-SEARCH requests
See original GitHub issueHi,
I am hoping to use node-ssdp server to advertise a custom UPnP-like device on my network. I’ve got it up and running and I can see that it is sending out multicast SSDP advertisements as expected. However, I also need it to be able to respond to multicast M-SEARCH requests too. Here, it falls down (or at least, there is no documentation explaining how to enable it).
My setup:
var ssdpServer = require('node-ssdp').Server;
ssdp = new ssdpServer({
location: require('ip').address() + '/desc.xml'
});
ssdp.addUSN('urn:codersaur-com:device:DeviceType:1');
ssdp.start();
A typical M-SEARCH multicast request (sent from a client):
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 4
ST: codersaur-com:device:DeviceType:1
Doing some debugging, I can see that the ssdpServer is simply ignoring multicast packets.
Following the advice here it seems the solution is to bind the socket to the multicast port (i.e. 1900) only. I have been able to do this by specifying the sourcePort in the configuration parameters to be the same, i.e.:
var ssdpServer = require('node-ssdp').Server;
ssdp = new ssdpServer({
location: require('ip').address() + '/desc.xml',
sourcePort: 1900,
});
ssdp.addUSN('urn:codersaur-com:device:DeviceType:1');
ssdp.start();
The SSDP server now binds to address: 'http://0.0.0.0:1900', ...
and is able to respond to multicast M-SEARCH requests properly with a unicast response to the originator of the M-SEARCH request.
However, this leaves me with some questions:
- is this the correct way to get node-ssdp to respond to multicast M-SEARCH requests?
- would it not be better for node-ssdp to bind two sockets on each interface (one for receiving multicast M-SEARCH requests, and another for sending/receiving all unicast traffic)?
- is sourcePort supposed to be used this way? I think there is possibly a mis-match between the code and the documentation as unicastBindPort is mentioned in the readme, but not the code (and vice-versa)?
Thanks, codersaur.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:5
Top GitHub Comments
Also, if this is the recommended way to get node-ssdp to respond to multicast M-SEARCH requests, then it’s worth pointing out that it doesn’t appear to add an appropriate time delay (as specified by the MX header).
UPnP Device Architecture 1.1
Also seeing this but nothing here seems to be helping 😞 Is there anything else anyone else tried? I’m on macOS. Seems like the
socket.on('message'
is never called! @troppoli @opichals