You are reading a single comment by @alexander-daniel and its replies. Click here to read the full conversation.
  • Thanks Gordon! I tried the dev IDE and it works a bit better, but I still can't make a proper POST. The CC3000 times out and restarts everytime, or I get a socket-1 error.

    Here is my code:

    var wlan = require("CC3000");
    var http = require("http");
    
    var data = JSON.stringify([{
        x : 0,
        y : 1,
        type : "scatter",
        mode : "markers"
    }]);
    
    var layout = JSON.stringify({
        fileopt : "extend",
        filename : "Espruino"
    });
    
    
    var payload = {
    un : "demos",
    key : "tj6mr52zgp",
    origin : "plot",
    platform : "rest",
    args : data,
    kwargs : layout,
    version : "0.0.1"
    };
    
    function request() {
      var urlpayload = "un="+payload.un+"&key="+payload.key+"&o­rigin="+payload.origin+"&platform="+payl­oad.platform+"&args="+payload.args+"&kwa­rgs="+payload.kwargs+"&version="+payload­.version;
      var options = {
      host: 'plot.ly',
      method: 'POST',
      path: '/clientresp',
      headers: {
              'Content-Type': 'application/x-www-form-urlencoded',
              'Content-Length': urlpayload.length
          }
    };
    
    var req = http.request(options, function(res) {
      console.log('STATUS: ' + res.statusCode);
      console.log('HEADERS: ' + JSON.stringify(res.headers));
      res.on('data', function (chunk) {
        console.log('BODY: ' + chunk);
      });
    });
    
    req.on('error', function(e) {
      console.log('problem with request: ' + e.message);
    });
    
    req.write(urlpayload);
    req.end();
    }
    
    
    wlan.connect( "evilfriends", "password", function (s) {
      if (s=="dhcp") {
        console.log('wifi connected!');
        request();
      }
    });
    

    It seems to be OK until it hits

    req.end()
    
About