0

I am running buildroot and iotjs on an iot device and I'm trying to make a post request to login and get an auth token. But I'm unable to call the API at all because I run into an error that says

"API Failed, problem with request: handshake failed: domian"

The same API works given I use the http version. The server I'm trying to call is hosted on an AWS EC2 instance behind cloudflare.

The code (not exactly the same but similar) used to call the API:

var https = require('https');

var options = {
  host: 'www.google.com',
  port: 443,
  path: '/upload',
  method: 'POST'
};

var req = https.request(options, function(res) {
  console.log('STATUS: ' + res.statusCode);
  console.log('HEADERS: ' + JSON.stringify(res.headers));
  res.setEncoding('utf8');
  res.on('data', function (chunk) {
    console.log('BODY: ' + chunk);
  });
});

req.on('error', function(e) {
  console.log('problem with request: ' + e.message);
});

// write data to request body
req.write('data\n');
req.write('data\n');
req.end();

Any help is appreciated thanks!

Raikan 10
  • 115
  • 5

0 Answers0