【问题标题】:Calling HTTPS request on google cloud function getting connect connect to server在谷歌云功能上调用 HTTPS 请求连接到服务器
【发布时间】:2017-04-03 05:01:56
【问题描述】:

我正在使用 http 触发器调用谷歌云功能上的 https 端点,但我得到了

{
   "type": "connection_error",
   "message": "Error occured while connecting to First API",
   "error": {
      "code": "ENOTFOUND",
      "errno": "ENOTFOUND",
      "syscall": "getaddrinfo",
      "hostname": "api-cert.payeezy.com",
      "host": "api-cert.payeezy.com",
      "port": 443
   }
}

同样的代码适用于亚马逊 lambda,有谁知道谷歌云功能是否需要特殊调整调用 https 服务器?我尝试使用 cors 但仍然报同样的错误。

我的代码是一个非常通用的使用 payeezy api 的 http 调用

    var nonce = Math.random() * 1000000000000000000;
    var timeInMillis = new Date().getTime();
    var requestJSON=JSON.stringify({
            method: 'credit_card',
            amount: '1299',
            currency_code: 'USD',
            credit_card: {
                card_number: '4788250000028291',
                cvv: '123',
                type: 'visa',
                exp_date: '1230',
                cardholder_name: 'Tom Eck'
            },
            billing_address: {
                street: '225 Liberty Street',
                city: 'NYC',
                state_province: 'NY',
                zip_postal_code: '10281',
                country: 'US'
            }
        });
    var headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'apikey': apikey,
        'token': merchant_token,
        'nonce': nonce,
        'timestamp':timeInMillis,
        'Authorization': getAuthorizationHeader(apikey, apisecret, requestJSON, merchant_token, nonce, timeInMillis)
    };
    
    var options = {
        host: "api-cert.payeezy.com",
        path: '/v1/transactions',
        method: "POST",
        headers: headers
    };
    var req1 = http.request(options);
    req1.on('response', responseHandler(callback));
    req1.on('error', errorHandler(callback));
    req1.write(requestJSON);
    req1.end();

【问题讨论】:

  • 从错误中可以看出api-cert.payeezy.com 不存在。
  • 您不能在 Spark 计划上发出外部 API 请求。

标签: node.js google-cloud-functions


【解决方案1】:

感谢詹姆斯丹尼尔的评论,我注意到谷歌功能只能使用火花计划调用谷歌自己的服务。 定价页面中有一个出站网络行 https://firebase.google.com/pricing/

【讨论】:

    猜你喜欢
    • 2018-12-01
    • 2019-12-25
    • 2017-09-10
    • 2021-01-25
    • 2019-01-23
    • 2013-08-16
    • 1970-01-01
    • 2019-04-01
    • 1970-01-01
    相关资源
    最近更新 更多