简体   繁体   English

在Google Cloud Function上调用HTTPS请求以获取连接连接到服务器

[英]Calling HTTPS request on google cloud function getting connect connect to server

I'm calling a https endpoint on google cloud function, with http triggers, but I got 我正在使用http触发器在google cloud函数上调用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
   }
}

Same exact code works on amazon lambda, does anyone know if google cloud function need special tweaks calling https servers? 相同的代码在Amazon Lambda上也可以使用,有人知道Google Cloud函数是否需要特殊的调整来调用https服务器吗? I tried using cors but still giving the same error. 我尝试使用cors,但仍给出相同的错误。

my code is a very generic http call using payeezy api 我的代码是使用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(); 

Thanks to James Daniel's comment, I notice google function can only call google's own service using spark plan. 感谢詹姆斯·丹尼尔(James Daniel)的评论,我注意到Google函数只能使用Spark计划调用Google自己的服务。 There's an outbound networking row in the pricing page https://firebase.google.com/pricing/ 定价页面https://firebase.google.com/pricing/中有一个出站网络行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM