Backendless Support
 
Not Covered by Support

API Calls fails

Hi I have a problem. Since I am on the free version of backendless I have 15 API calls per minute. However in my class I am making only 5 API calls. I have implemented the Thread.sleep(20000); 3 times to help solving the problem. Furthermore I have used a CountDownLatch object to stop java to advance to fast during run time. I have 5 methods making API calls but only one of the method does not do it. It skips the AsyncCallback, meaning the countdown of the latch will not happen, since I have put a latch.countDown() in the handleFault callback as well as in the handleResponse callback.

But here is the interresting part. if I comment one method (which makes an API call) out, meaning it will not execute. That particular method (which skips the API calls) works fine. See Attached text file and code snippets.

What must I do to solve this problem?

Must I buy the Developer Package to solve it?

Regards

Rhonwen

Leave a Comment

Comments (6)

photo
1

Hi Rhonwen,

It appears to be a problem in your implementation rather than our API. Please use a debugger to step through the code to understand why some parts are not invoked. If you detect that something is not right with the API, please create a minimalistic example demonstrating the issue and share it with us.

Regards,

Mark

photo
1

Hi, I really do not know where am I at fault if it comes to the implementation of those methods or code for that matter. All I do is using a separate thread, since the latches doesn't work well on the main thread. (In this context at least). That is why I created the AsyncTask class to help me solve that problem. All my code works perfectly fine including GetParent(String parentID). I can swap it with one of the methods I am calling just before and he will work. I tested it, but let me give a more specific scope. Look at this code below:

  1. latch = new CountDownLatch(1);
  2. GetAdress(strings[0]); // This method is working fine
  3. latch.await();
  4. // Thread.sleep(20000);
  5. latch = new CountDownLatch(1);
  6. GetLearner(strings[0]);// This method is working fine
  7. latch.await();
  8. // Thread.sleep(20000);
  9. latch = new CountDownLatch(1);
  10. GetMedicalAid(strings[0]);// This method is working fine
  11. latch.await();
  12. // Thread.sleep(20000);
  13. latch = new CountDownLatch(1);
  14. GetParent(strings[0]); //This method is working fine
  15. latch.await();
  16. Log.i(ListLearners.class.getName(), "Done Reading Data");

The Problem:

Swap the GetParent(strings[0]) with GetMedicalAid(strings[0])...Meaning the GetParent(strings[0]) are on line 10 and GetMedicalAid(strings[0]) are on line 14. You can comment GetMedicalAid(strings[0]) with the applicable latches out. The GetParents(strings[0]) will work as it should(Meaning the API call was a success). Since GetParents(strings[0]) is called last (Meaning it is the 5th API call I made in that specific class). It skips the AsyncCallback.

Regards

Rhonwen

photo
1

Hello Rhonwen,

you may use some sniffer(for example charles) to count how many times your application made a call to backendless. But you have to make sure that you use backendless only with one client.

photo
1

Hi, the issue wasn't the API calls. I purchased the developer package and it still didn't work. I need to do that anyways so I did not waste money. :)

It was the latch. I did not Countdown the latch in the Medical Aid Method. The program could not execute any further, since the latch stopped it in doing so.

Thank you for your assistance. Appreciate it.

Sergey Kukurudzyak, may I ask where do I find the documentation for the sniffer?

photo
1

backendless has no documentation about for any sniffer. Sniffer is a computer program or piece of computer hardware that can intercept and log traffic that passes over a digital network or part of a network. Read more here https://en.wikipedia.org/wiki/Packet_analyzer

photo
1

Ok thank you for the feedback. I will read up on that topic.