• Ahh, yes - that's definitely your issue.

    With WIZnet, when you create the Websocket, I think it connects immediately - which might cause a delay which would stop everything getting uploaded correctly.

    Even using a setTimeout would work:

    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;
    
    setTimeout(function() {
      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");
      });
    }, 1000);
    
About

Avatar for Gordon @Gordon started