SSDP โ€“ Simple Service Discovery Protocol

I have a certain need to make sure that the equipment that sends information via MQTT is present or not in my network.

So I would like to know if there is any node that uses the SSDP protocol?

Or if there is any initiative in this direction.

I even found this npm package on the web, but as it has no documentation nor is it available in the palette. I was suspicious.

node-red-contrib-ssdp-discover - npm

Well if you follow that link you see:

so I would ignore it.

If you didn't find a node searching the Flow library then there isn't one publicly avaliable.

Could you use MQTT LWT instead?

I have a device on the network that is a Raspberry PI.

This equipment has a little program in python that sends data to the MQTT server.

I would like to know through my system developed in NODE-RED that this equipment is connected to the network.

Of course I'm only going to use this in case it's not sending data to MQTT, because if it's sending data... I don't need to discover it on the network.

OK, so you are trying to identify the situation where it is on the network, but not connected to the MQTT broker for some reason. I generally use the ping node for that type of scenario.

A NR flow on remote Pies can send a "heartbeat" MQTT message every 10 seconds say.
A flow on the central NR / mosquitto server sends a notificaton if no message arrives for 20 seconds.

But the MQTT node's "close" and "will" offer the same notifications.
If I shutdown the remote Pi, my main server gets the "close" message.
If I just pull the plug, after a timeout period it gets the "will" message.
Somehow it's hard to trust these messages though so I generally use the heartbeat approach.

Will (LWT) messages are described for Python at

The problem is that the ping node you need to know what the IP of the equipment is.

In this case, I already use the ping node in other situations

I don't think that's the concept.
Maybe I didn't explain it right. Or the translator didn't allow me to say what I wanted.

You are focused on MQTT communication.

My problem is not the MQTT.

I need something that tells me there on the NODE-RED Server that there is "Some raspberry PI" on the network.

My equipment at the end that sends information via mqtt

it is not connected directly and it is not a "Reliable" equipment plugged in all the time.

It is a device that plugs and unplugs all the time... through a cable.

My raspberry pi sticks to a diver's suit.

Which is connected by a cable... The power and connection is not stable.

1 Like

Perhaps we are indeed suffering from lack of a common language. Apologies if I'm getting confused.

I am not focussed on the MQTT communication, it just happens that MQTT seems to offer what you are seeking.

Here's how it works:

  • The birth, close and will messages are all sent when the underwater device first connects to the MQTT broker. So these are all safe in the broker up on dry land.
  • If the connection to the submerged device is lost, either the close or will message (depending on how graceful the disconnect was) is passed on to subscribers.

If Node-red receives a message on (for exampe) topic /diver/birth, it knows that there is some Raspberry Pi online.
If it receives a message on /diver/disconnect or on /diver/broken, it knows that the Raspberry Pi is no longer online.

I have some doubts if this will actually work.

Because the program that sends the information is written in a python program. This program is flawed.

for example:

It's working, remove the network cable and it stops...Put the network cable and it doesn't come back.

Can I have any problem with running python program on raspberry pi

There is another possibility.

If a particular piece of equipment is faulty. Due to physical connection problems, another piece of equipment will probably be installed in its place.

So I need to install an SSDP on the network.

Because I want through the server.

Find out which devices are on the network.

Some ways to detect if there is "Some Raspberry Pi" on the network...

  1. sudo nmap -sn | awk '/Nmap scan report for/{printf $5;}/MAC Address:/{print "|"substr($0, index($0,$3)) }'|E8:48:B8:F6:BE:CF (Unknown)|B6:FB:E4:63:00:67 (Unknown)|B8:27:EB:34:EB:55 (Raspberry Pi Foundation)|E4:5F:01:7F:FE:01 (Raspberry Pi Trading)|4C:34:88:97:61:75 (Intel Corporate)|24:62:AB:25:74:94 (Espressif)|24:62:AB:25:65:AA (Espressif)|B4:E6:2D:75:D1:74 (Espressif)

NB You have to ensure that nmap has an up-to date list including all the MAC address ranges belonging to Raspberry Pi Trading and Raspberry Pi Foundation.

  1. Ping the IP address revealed by (1)
    ping -c 2

PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=370 ms
64 bytes from icmp_seq=2 ttl=64 time=2.13 ms

--- ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 2ms
rtt min/avg/max/mdev = 2.131/186.178/370.225/184.047 ms

  1. Ping the hostname. (Needs Apple Bonjour service on the computer sending ping)
    ping -c 2 CrucialPi.local

PING CrucialPi.local ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=64 time=2.38 ms
64 bytes from ( icmp_seq=2 ttl=64 time=5.03 ms

--- CrucialPi.local ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 2ms
rtt min/avg/max/mdev = 2.380/3.702/5.025/1.323 ms

  1. MQTT birth, disconnect and will messages from python on the remote device.

  2. MQTT birth, disconnect and will messages from Node-red on the remote device (bypassing unreliable python script). The message content could be the IP address to be used for option 2.

  3. Heartbeat messages from Node-red on the remote device.

  4. No doubt there are many other possibilities.

Note that the Raspberry Pi has a hardware watchdog which can be set up to reboot if the network goes down, thereby resetting your python script


I love the quote above.

I will study how to implement.

How could I run this nMAP command? inside NODE-Rede and display the result on a screen ?

Could the "EXEC" node do that?

Where do I find this watchdog? On the raspberry PI?

I use the DietPI operating system.

Then I think you should revisit your Python code, It is for sure possible to write a Python program that detects network down and then reconnects and continuos when network is back

NMAP is extra software that can be installed at the OS level using apt. I run a BASH shell script on a CRON timer that runs nmap and uses its XML output option to create a temporary file and then I call a node-red http-in endpoint to trigger a flow that reads the temporary file and process it in node-red. I can share the script if needed. I use it to keep track of all of the devices that appear on my network.

The exec node simply runs an OS command. Much as you would at a terminal command line prompt.

Much has been written about using Watchdog on the Pi, there are loads of tutorials.

I have been using your original flow with some success, but I think I read that you have updated it. Any chance of publishing it (I have the nmap script which is also working well already running)