0

I'm calling a third party API to send transactional SMS to the mobile numbers. While executing the function by calling from the android client, the function execution gives the code 200. But the log text shows ignoring exception from the finished function. I have seen many questions about this. None of them solved my problem and non-related to my problem.

'use-strict'

var admin = require("firebase-admin");
var functions = require('firebase-functions');
var serviceAccount = require("./ServiceKey.json");
var http = require("http");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://atithikhana2.firebaseio.com/"
});


var options = {
  "method": "POST",
  "hostname": "2factor.in",
  "port": null,
  "path": "/API/V1/b5b8cefe-d3f8-11e9-ade6-0200cd936042/ADDON_SERVICES/SEND/TSMS",
  "headers": {}
};

exports.sendTNS = functions.https.onCall((data, context) => { 

 const var1 = data.var1;
 const var2 = data.var2;
 const var3 = data.var3;
 const var4 = data.var4;
 const phone_number = data.phone_number;

var req = http.request(options, function (res) {
  var chunks = [];
  res.on("data", function (chunk) {
    chunks.push(chunk);
  });
  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ From: 'AKINFO',
  To: 'phone_number',
  TemplateName: 'Customer_Template',
  VAR1: 'var1',
  VAR2: 'var2',
  VAR3: 'var3',
  vAR4: 'var4'}));
req.end();

  });


6:02:24.911 PM
sendTNS
Function execution started
6:02:24.911 PM
sendTNS
Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions
6:02:24.917 PM
sendTNS
Function execution took 7 ms, finished with status code: 200
6:02:24.926 PM
sendTNS
Ignoring exception from a finished function
Pradeep
  • 798
  • 1
  • 7
  • 18
  • Please edit your question to include the exact error message and complete stack trace that you get. – Frank van Puffelen Sep 15 '19 at 13:45
  • added the console logs – Pradeep Sep 15 '19 at 13:56
  • Is your project on a paid plan? Only projects on a paid plan can call non-Google-owned URLs. See https://stackoverflow.com/search?q=%5Bgoogle-cloud-functions%5D+Billing+account+not+configured.+External+network+is+not+accessible – Frank van Puffelen Sep 15 '19 at 14:06
  • Billing account not configured is appearing even in fcm message sendings. I dont think thats a problem. – Pradeep Sep 15 '19 at 14:21
  • Is your project on a paid plan? – Frank van Puffelen Sep 15 '19 at 14:22
  • No sir. I'm using spark plan. – Pradeep Sep 15 '19 at 14:30
  • As the warning says, calling external networks is not allowed in that case. The fact that the message also appears when calling internal networks, doesn't change that. – Frank van Puffelen Sep 15 '19 at 14:34
  • @FrankvanPuffelen Sir, Should I pay seperately for the third party API call, Or it is enough to be in the blaze plan? – Pradeep Sep 17 '19 at 11:06
  • Your project needs to be on a paid plan, that is all. If you're on the Blaze/pay-as-you-go plan, you have a free quota. If you go beyond the free quota you will be charged what is described on the [pricing page](https://firebase.google.com/pricing), but if you stay below the free quota there won't be a charge. The billing-plan requirement is purely in place to prevent abuse of Cloud Functions against 3rd party services. – Frank van Puffelen Sep 17 '19 at 11:26

0 Answers0