• Hello Gordon,
    thanks for your wonderful work, I love this javascript based hardware (use it for home automation). Unlikely with one problem concerning websocket.

    My espruino is monitoring some temperatures which I would like to stream via websocket to my dataserver. I tried some firmwares (also the latest cutting edge espruino_1v84.155_espruino_1r3_wiznet.bin) but have issues with it. Generally this latest version feels better then the older ones, but it freezes my espruino console on the left side of the Chrome IDE (it is not possible to type something into it, I use ist for reset() sometimes).

    My test script (as attached) is basically websocket trying to use setInterval every 2 seconds. If you run it with commented websocket part (line 17 - 37) the timer works and the script gets read in completely. If you uncomment lint 17-37 the setInterval timer never gets to run and the last console.log on line 40 sometimes shows up sometimes not (on startup).
    The espruino "hangs" as I wrote above and needs to be plugged out and in again every time I want to flash a new script. But the websocket connection is correctly set and also the first message (line 27 ws.send(data); is showing up on the dataserver)

    I really tried a lot of things and for me it looks like there is a problem with the event loop, maybe this ws.on('open',... ) never finishes and blocks the event loop (would explain the odd behaviour of the timer/console.logs).

    It would be great if you have an idea to put me in the right direction to solve this issue (I hope I haven't missed something and the problem is all mine).

    Many thanks and a happy / successful 2016!

    Best regards, Manuel

    var eth = require("WIZnet").connect();
    eth.setIP({ ip : "192.168.0.10" });
    
    var data = JSON.stringify([{
      topic: 'espruino',
      messages: ["199-hello\nldskjfds"]
    }]);
    
    var t = setInterval(function() {
      console.log("Write  should be done every 2 seconds");
      //ws.send(data);
    }, 2000);
    
    var WebSocket = require("ws");
    
    /*
    var ws = new WebSocket("192.168.0.6",{
      port: 8080,
      protocolVersion: 13,
      origin: 'Espruino',
      keepAlive: 30  // Ping Interval in seconds.
    });
    
    ws.on('open', function() {
      console.log("Connected to server");
      //Send message to server
      ws.send(data);
      console.log("Sent first time");
    });
    
    ws.on('message', function(msg) {
      console.log("MSG: " + msg);
    });
    
    ws.on('close', function() {
      console.log("Connection closed");
    });
    */
    
    console.log("Script read in completely");
    
About

Avatar for DrAzzy @DrAzzy started