Trying to start a Websocket

Posted on
  • I'm trying to start a websocket server through the ESP8266 but keep receiving an error saying that Constructor should be a function and not undefined. This is my code after connecting the ESP to wifi. What is going wrong here? I have node and ws installed through terminal.

    var WebSocketServer = require('ws').Server,
    wss = new WebSocketServer({port:8080});

    wss.on('connection', function (wss) {
    wss.on('message', function (message) {

    console.log('received: %s', message);
    

    });

    setInterval(

    () => ws.send(`${new Date()}`),
    1000
    

    );
    });

About

Trying to start a Websocket

Posted by Avatar for user105886 @user105886

Actions