Saturday, 8 April 2017

Not getting any traffic listening for UPNP

I have a bit of NodeJS code that listens for broadcast messages sent for UPNP. One code snippet listens on port 1900, the other bit of code uses dgram for UDP on port 1900. Neither pieces of code return any messages. I verified with a utility that there is traffic being broadcasted on the network. I don't run both pieces of code at the same time, this way I avoid any port issues. Using netstat -a I am able to see the ports in use when the code is running.

Why am I not receiving these UPNP messages?

//DServer for UDP
/*dserver = dgram.createSocket('udp4');
dserver.bind('1900', () => {
    console.log('Listening on address:' + dserver.address());
});
dserver.on('error', (err) => {
    console.log('UDP Server ERROR:' + err);
    dserver.close();
});
dserver.on('close', () => {
    console.log('UDP Server closed');
});
dserver.on('listening', () => {
    console.log('UDP Server listening');
});
dserver.on('message', (msg, rinfo) => {
    console.log(msg + '\n' + rinfo);
});*/
//TCP Server ( for testing )
let dserver = net.createServer((socket) => {
    socket.on('data', (data) => {
        console.log("DATA:" + data.toString());
    }).on('error', (err) => {
        console.trace('DServer socket.on: error');
        console.error(err.stack);
    });
}).on('listening', () => {
    console.log('DServer Listening');
}).on('connection', () => {
    console.log('DServer got a connection');
}).on('close', () => {
    //stays open if client closes conx
    console.log('DServer Closed');
}).on('error', (err) => {
    console.trace('DServer.on: error');
    console.error(err.stack);
});
dserver.listen({ port: 1900 }, () => {
    console.log('DServer Started Listening');
});



via allegory

No comments:

Post a Comment