Azure功能请求中端口443上的EACCESS错误

时间:2017-06-07 13:14:52

标签: node.js azure https azure-functions

我正在向服务器发出https请求,这需要TLS 1.2。

向该服务器发出GET请求在我的浏览器上运行,在CURL中,但在我的Azure功能中,我收到此错误:

Error: connect EACCES 127.0.0.1:443
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1081:14)
code: 'EACCES',
errno: 'EACCES',
syscall: 'connect',
address: '127.0.0.1',
port: 443

此请求在azure函数内完成。我的azure函数没有自定义域,因此它应该使用SSL吗?我错过了什么?

这是我的要求:

var options = {
        url: 'https://somesite.ca/somepath/Services/something.asmx/GetTrustedAutorizationTicket',
        qs: {UserName: 'username', Domain: '', Password: 'pwd', ClearText: 'true'},
        headers: {
            'Content-Type': 'text/xml',
        }
    }

    var req = https.get(options, function(res) {...

TIA

1 个答案:

答案 0 :(得分:3)

url中没有options。您正在寻找hostnamepath

E.g。

const https = require('https');

const options = {
  hostname: 'somesite.ca',
  port: 443,
  path: '/somepath/Services/something.asmx/GetTrustedAutorizationTicket',
  method: 'GET'
};

const req = https.request(options, (res) => {
  console.log('statusCode:', res.statusCode);
  console.log('headers:', res.headers);
  ...

参考:https://nodejs.org/api/https.html#https_https_request_options_callback