SSDP Client doesn't find Server advertise
johnmurphy01 opened this issue · 6 comments
I've implemented a server/client implementation of node-ssdp using the examples provided. Everything "appears" to work but my client does not pick up the server's packet. I get a lot of different payloads from different devices/locations but not the payload from my node-ssdp server.
I'm running on the same machine and I'm running on OSX. I have two separate node projects: one for my client and one for my server.
I've also verified that the server is actually broadcasting by running:
sudo tcpdump -i en0 -s 0 -B 524288 -w ~/Desktop/DumpFile01.pcap
and then reading the info by
tcpdump -s 0 -n -e -x -vvv -r ~/Desktop/DumpFile01.pcap
Any suggestions? Is it possible that I can't run the server and client on the same machine?
Here are my implementations just in case I messed something up:
Server
var SSDP = require('node-ssdp').Server
, server = new SSDP({
//unicastHost: '192.168.11.63',
location: 'http://' + require('ip').address() + ':33333',
ssdpPort: 33333
})
console.log(require('ip').address())
server.addUSN('upnp:rootdevice')
server.addUSN('urn:schemas-upnp-org:device:MediaServer:1')
server.addUSN('urn:schemas-upnp-org:service:ContentDirectory:1')
server.addUSN('urn:schemas-upnp-org:service:ConnectionManager:1')
server.on('advertise-alive', function (heads) {
console.log('advertise-alive', heads)
// Expire old devices from your cache.
// Register advertising device somewhere (as designated in http headers heads)
})
server.on('advertise-bye', function (heads) {
console.log('advertise-bye', heads)
// Remove specified device from cache.
})
// start server on all interfaces
console.log('starting ssdp server')
server.start()
Client
var ssdp = require('node-ssdp').Client
, client = new ssdp({
// unicastHost: '192.168.11.63'
})
client.on('notify', function () {
//console.log('Got a notification.')
})
client.on('response', function inResponse(headers, code, rinfo) {
console.log('Got a response to an m-search:\n%d\n%s\n%s', code, JSON.stringify(headers, null, ' '), JSON.stringify(rinfo, null, ' '))
})
client.search('ssdp:all')
// Or maybe if you want to scour for everything after 5 seconds
/*setTimeout(function() {
client.search('ssdp:all')
}, 5000)*/
// And after 10 seconds, you want to stop
setTimeout(function () {
client.stop()
}, 10000)
I tried running the server on one machine and the client on another. This also did not work. I also confirmed that the packets were being sent via Wireshark on the client machine. It is sending a NOTIFY header with all of the rest of the info from the server.
Hi @johnmurphy01! Could you try removing ssdpPort: 33333
from your server constructor and see if that helps?
@diversario thanks for the response! I removed ssdpPort: 33333
from the server's constructor but that didn't seem to make a difference.
It's very confusing to me because I've since gotten a UDP multicast solution up and running using dgram
for the broadcaster and a .NET C# solution for the client. I was under the impression that SSDP is essentially UDP multicast but maybe I'm mistaken.
No, it is UDP multicast, you're correct. There is likely a bug in the server part of this module because this has came up multiple times.
Could you try this, please:
var SSDP = require('node-ssdp').Server
, server = new SSDP({
location: 'http://' + require('ip').address() + ':33333',
sourcePort: 1900
})
Adding sourcePort to options seems to fix the problem. Thanks! been trying for a solution =D
I've defaulted sourcePort to the correct 1900
in v3.3.0 – it really should've been 1900 for the server all along by default.