Business Logic-Cannot allocate new thread


Am trying to make an external Api Call from within my Cloud Code to validate a sign in user token but getting the error

{"code":0,"message":"Cannot allocate new thread. You can remove this limitation by purchasing a function pack in Backendless Marketplace.","errorData":{}}

It’s the only thing being done in the handleEvent code block of the event handler other than the HashMap result being sent back to the client side.

Is this possible, to call an external Api from a Custom Event Handler in Cloud Code? Am on the Developer price option.


I’m getting a similar message when I attempt to access a third party API:

[ERROR] You have no permission to create thread in CodeRunner secure group.

Basically a deal breaker for me, is there any way to access third party API without throwing a thread error?

yes, you can use URLConnection to call external API

or you can buy extra threads in the backendless marketplace

I am using URLConnection however I’m still getting the above error. What is the difference between my error and the error that George posted?

URLConnection only? What about other networking libraries e.g Retrofit which is what i have implemented and getting the error, could this be the cause?


For your reference I fixed my issue as per here:

Thank you Mitchell, I’ll try it out and revert.


Mitchell’s answer below can actually explain the cause for lots of libraries, too, in case they use URLConnection (which is very likely). Otherwise this is still out of Backendless scope, since you’ll have to figure out how and why the library is creating additional threads - either by yourself or by asking the library authors.