question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSDP server does not respond to mutlicast M-SEARCH requests

See original GitHub issue

Hi,

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:

  1. is this the correct way to get node-ssdp to respond to multicast M-SEARCH requests?
  2. 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)?
  3. 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:open
  • Created 6 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

1reaction
codersaurcommented, Apr 2, 2017

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

Devices responding to a multicast M-SEARCH SHOULD wait a random period of time between 0 seconds and the number of seconds specified in the MX field value of the search request before responding, in order to avoid flooding the requesting control point with search responses from multiple devices.

0reactions
simonmitchellcommented, Feb 5, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSDP M-search does not work for unicast - single IP
I believe bind is for server side.The multicast discovery is working fine without bind. – samiksc. Sep 3, 2019 at 5:14.
Read more >
SSDP discovery not working? What a… - Apple Developer
Hey! I have been trying the last few days to discover devices in my network using NWConnection and NWConnectionGroup by sending a SSDP...
Read more >
SSDP: How to find local devices - Medium
Response. A request message is when a device transmits an M-SEARCH message onto the network.
Read more >
How a UPnP Search works - Pelco Support Community
Note: No body is present in requests with method M-SEARCH. ... Devices responding to a multicast M-SEARCH SHOULD wait a random period of ......
Read more >
A New Twist In SSDP Attacks - Netscout
many SSDP server implementations will answer requests sent to unicast addresses (e.g. 1.1.1.1), not just the well-known link-local multicast addresses for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found