• Hi! I'm having an issue that I don't know how to fix.

    I'm using code similar to this:

    var wlan = require("CC3000").connect();
    wlan.connect("SSID","PASSWORD",function(­s){
      if (s=="dhcp") {
        var payload = {
          NodeId:1,
          Channel:"temperature",
          Value:23.5,
          Metric:"celcius"
        };
        var strPayload = JSON.stringify(payload);
        var options = {
          host: 'requestb.in',
          port: '80',
          path:'/wt3kigwt',
          method:'POST'
        };
        var req = require("http").request(options,function­(res) {
            console.log('STATUS: ' + res.statusCode);
            console.log('HEADERS: ' + JSON.stringify(res.headers));
            res.on('data', function(data) {
              console.log("   " + data);
            });
            res.on('close', function() {
              console.log("closed");
            });
        });
        req.on('error', function(e) {
          console.log('problem with request: ' + e.message);
        });
        req.write(strPayload);
        req.end();
      }
    });
    

    Check results here http://requestb.in/wt3kigwt?inspect

    For this I get Content-Length: 0 which is a problem because my API needs this header to function properly (can't do anything about that) so then; let's try to add the header:

    var options = {
          host: 'requestb.in',
          port: '80',
          path:'/wt3kigwt',
          method:'POST',
          headers: { "Content-Length": strPayload.length }
        };
    

    Now, one of two things happens:

    1. Socket error -1 while sending
    2. The espruino simply hangs, last output is >echo();

    I have tested this with both 1v73 and 1v74, I have yet to make a successful POST to my API.

    Any ideas?

About