• Given the following code sample, I can fairly reliably have all the "stylesheets" fail to load when there is CPU load during try to respond to their HTTP requests.

    Dial var junk = generateJunk(45); up and down to experiment, I got it as far as 1024 when using indexOK, and up to about 60 using indexBAD.

    If the indexBAD page loads first time, try refreshing a few times, eventually it should stall out.

    I'm not sure if anything can be done here. Ideally no matter how intensive the CPU task the HTTP request would eventually complete.

    var wifi = require("EspruinoWiFi");
    var http = require('http');
    var indexOK = "<html><head><link rel='stylesheet' href='1'><link rel='stylesheet' href='2'></head><body>OK!</body></html>"­;
    var indexBAD = "<html><head><link rel='stylesheet' href='1'><link rel='stylesheet' href='2'><link rel='stylesheet' href='3'></head><body>NOT OK!</body></html>";
    var indexVERYBAD = "<html><head><link rel='stylesheet' href='1'><link rel='stylesheet' href='2'><link rel='stylesheet' href='3'><link rel='stylesheet' href='4'></head><body>NOT OK!</body></html>";
    
    function generateJunk(length) {
      var text = "";
      var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm­nopqrstuvwxyz0123456789";
    
      for(var i = 0; i < length; i++) {
        text += possible.charAt(Math.floor(Math.random()­ * possible.length));
      }
    
      return text;
    }
    
    wifi.startAP('test', {
      password: 'mytestap123',
      authMode: 'wpa2',
    }, function(err) {
      if (err) { throw err; }
    
      http.createServer(function(req, res) {
        switch (req.url) {
          case '/':
            res.writeHead(200, {
              "Content-Type": "text/html",
            });
    //        res.end(indexOK);
            res.end(indexBAD);
            break;
          default:
            // Generate some CPU load
            var junk = generateJunk(45);
            //console.log(process.memory());
            res.writeHead(200, {
              "Content-Type": "text/css",
            });
            res.end(junk);
        }
      }).listen(80);
    });
    
About

Avatar for dave_irvine @dave_irvine started