Start a new topic

Common causes of 503 Error when accessing API?

Hi im new to chargebee and am trying to test a subscription check using their API. Ive pretty much used their code verbatim from their docs, substituting my own sandbox site and API key of course. The code below is all im doing but I have been 

checkSubscription = () => {
    var chargebee = require("chargebee");
    chargebee.configure({site : "escape-overseer-test", 
        api_key : "test_TCwzWlKEcumk4Jdu96DZ4qZUFACR0HAPl"});
    chargebee.subscription.retrieve("cbdemo_dave-sub1").request(function(error,result) {
      if(error){
        //handle error
        console.log(error);
      }else{
        console.log(result);
        var subscription = result.subscription;
        var customer = result.customer;
        var card = result.card;
      }
    });
  }


This code is all im running from my JS app. but every time I get a 503 "connection error while making request"


Anybody ran into this and care to share their solution? I already attempted to contact support directly for help but havent heard back in about a week so Im reaching out to you now


1 person likes this idea

Hello Chris, 


Thank you for considering Chargebee for your billing requirements.

Sorry about the trouble you are facing with the retrieve subscription API.


The API request you shared here it seems to work as intended returning the subscription details, I did run a test with your code intact. 

Considering that you are receiving 503 (server response), I was wondering if you have any proxy/intermediate processor in the flow which could be returning this error? Could you help me understand how & where you are calling this endpoint.


Also I see that you have also contact our support team, one of my colleagues will get back to you on that thready today.


Regards, 

Sanjay 

Chargebee Solutions Team.

Hello,


I call this function to open a checkout popup:  

chargebee.hosted_page.checkout_new({
    subscription : {
      plan_id : "premium-300"
    },
    //customer: {
    //  id: req.body.customer_id
    //}
  }).request(function(error,result){
    if(error){
      //handle error
      console.log(error);
    }else{
      res.send(result.hosted_page);
    }
  });

 It works perfectly in local, but when I upload it to "firebase functions", it doesn't work.


This is the error object:

 

{"message":"connection error while making request.","type":"io_error","api_error_code":"connection_error","http_status_code":503,"http_code":503,"error_code":"connection_error","detail":{"errno":"EAI_AGAIN","code":"EAI_AGAIN","syscall":"getaddrinfo","hostname":"superpopi-test.chargebee.com","host":"superpopi-test.chargebee.com","port":443}}

 I'm running the code on a test-site. Is there any limitation on this? It should work when I call the function locally and call it from firebase functions, shouldn't it?


Thanks,

Hello,


I solved my problem!.

If you are using Firebase Functions to access Chargebee API(or any other API), the free plan will block your requests with a "503 connection error while making request" error, so you need to upgrade your plan to flame or blaze plan.


Regards,

Login or Signup to post a comment