• Hi,

    I have a small ESP8266 module which is supposed to receive simple data via simple TCP. The net module should do that and it works mostly:

    var server = net.createServer(function(socket) {
      socket.on('data', function(data) {
        try {
          let a=JSON.parse(data);
          console.log(">"+JSON.stringify(a));
        } catch(e) {
          console.log("ERROR: ", e);
        }
      });
      socket.end();
    });
    
    server.listen(1234);
    

    On the sender side I do a simple test via netcat:

    for i in {0..4} ; do echo "{'toggle':$i}" | nc 192.168.21.105 1234 ; done
    

    But what I get on the Espruino side is:

    {"toggle":0}
    {"toggle":2}
    {"toggle":3}
    {"toggle":4}
    {"toggle":0}
    {"toggle":1}
    {"toggle":3}
    {"toggle":4}
    {"toggle":0}
    {"toggle":1}
    {"toggle":3}
    {"toggle":4}
    {"toggle":0}
    {"toggle":1}
    {"toggle":1}
    {"toggle":2}
    {"toggle":3}
    {"toggle":4}

    which is not what I'd expect from TCP. I should see 0, 1, 2, 3, 4.
    Even if I send one string at a time (and not 5 in a loop), it gets lost in about 20% of the cases.

    Am I doing something wrong? Is the net module on ESP8266 not working reliably?

About

Avatar for HaraldK @HaraldK started