Search code examples
javascriptnode.jsdatagram

JS Error: missing ) after argument list


I'm trying to make an App in HbbTV to search for Hue-lamps, for this I need a upnp search. But my Chrome is just showing an error that shouldn't be there, in my opinion.

    const dgram = require('dgram');
    const search = new Buffer([
    'M-SEARCH * HTTP/1.1',
    'HOST: 239.255.255.250:1900',
    'MAN: "ssdp:discover"',
    'MX: 3',
    'ST: upnp:rootdevice'
    ].join('\r\n'));

    const socket = dgram.createSocket('udp4');

    socket.on('listening', () => {
    socket.addMembership('239.255.255.250');
    socket.send(search, 0, search.length, 1900, 239.255.255.250); 
    });

    socket.on('message', (message) => {
    console.log(message.toString());
    });
    socket.bind(1900);

It shows me an error in line 14:

SyntaxError: missing ) after argument list

Am I overseeing anything, or is something else wrong?

Best regards


Solution

  • You've missed '' for 239.255.255.250 in next line:

    socket.send(search, 0, search.length, 1900, 239.255.255.250);