• Your code above is not like the client here - the port is passed as an option

    http://www.espruino.com/ws

    The client assumes there is a server on that ip and port - what do you have running as a server?

  • I tried the example but that didn't work either. Infact the code didn't work on the desktop either.. When running like a Websocket client . I was getting a "invalid url" error on the desktop.

    I changed the code to what it is now and atleast it began working with a WebSocket server (code below) and the WebSocket client when both are running on the desktop

    var WebSocketServer = require('ws').Server,
        wss = new WebSocketServer({
            port: 8080
        });
    
    wss.on('connection', function connection(ws) {
        ws.room = [];
        ws.send("User Joined");
    
        ws.on('message', function(message) {
    
    
            console.log("Msg from client - " + message);
            ws.send("Echo from Server " + message);
          
        });
    
        ws.on('error', function(er) {
            console.log(er);
        })
    
    
        ws.on('close', function() {
            console.log('Connection closed')
        })
    });
    
About

Avatar for Wilberforce @Wilberforce started