(npm install node-ssdp
)의 서버/클라이언트 구현을 구현했습니다. 모든 것이 "작동"하지만 클라이언트는 서버의 패킷을 선택하지 않습니다. 다른 기기/위치에서 많은 페이로드를 받고 있지만 node-ssdp
서버에서는 페이로드가 아닙니다.노드 SSDP 클라이언트가 서버 브로드 캐스트를 찾지 못함
동일한 컴퓨터에서 실행 중이며 OSX에서 실행 중입니다. 두 개의 개별 노드 프로젝트가 있습니다. 하나는 클라이언트 용이고 다른 하나는 내 서버 용입니다.
참고 : 루프백 등의 문제가있는 경우에 대비해 한 컴퓨터에서 클라이언트를 실행하고 다른 컴퓨터에서 클라이언트를 실행 해 보았습니다. 또한 Wireshark를 통해 서버의 패킷이 클라이언트 시스템에 의해 읽혀지고 있음을 확인했습니다. 헤더에 NOTIFY * HTTP/1.1
을 보냅니다.
서버
var SSDP = require('node-ssdp').Server
, server = new SSDP({
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()
클라이언트
var ssdp = require('node-ssdp').Client
, client = new ssdp({
})
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')
// And after 10 seconds, you want to stop
setTimeout(function() {
client.stop()
}, 10000)
내가 아이디어에서 실행하고 있습니다 : 여기
는 클라이언트와 서버에 대한 내 구현입니다. 이전에 UDP 멀티 캐스트 솔루션을 구현했기 때문에 이상합니다. SSDP는 내가 알고있는 것에서부터 UDP 멀티 캐스트를 제공합니다.