Backendless & Twilio - External Host

Hi guys, sorry for the basic question.

I’m trying to connect send SMS through Twilio from Backendless Custom Business Logic with Java. I send the sms successfully on Development. However, when I deployed my CBL code, there was an error, the log was: org/apache/http/auth/Credentials.

I have added “api.twilio.com” (approved) and “demo.twilio.com” (pending) as External Host. Is it the right way to do it? Am I missing something?

Thanks before.
Victor.

I suspect you missed the apache class from the deployment. Make sure all the dependencies are included into the jar file you deploy:

https://backendless.com/documentation/api-engine/apieng_service_deployment.htm

Regards,
Mark

Thanks for the answer, Mark.

I tried creating a New Hosted Service as described in https://backendless.com/documentation/api-engine/apieng_service_deployment.htm. It asked for “Service binaries” which I can’t find any explanation for. I tried uploading twilio-java-sdk-6.3.0.jar as well as my compiled fat jar, but the dialog box just stopped after a while without any message. Tried tens of times with various browser, but still cannot upload the binary.

What is exactly the file I need to upload as “Service binaries”?

Thanks,
Victor

Victor,

The documentation is pretty clear (at least to me):

“Before the code is deployed, it must be packaged into a fat .jar file which contains both classes for the service code and all the dependencies.”

There must be ONE jar file that contains your code and any dependencies including one for twilio. It is important that the jar does not contain other jars, all dependencies must be expanded within the final jar.

Mark

Hi Mark,

So I’ve compiled the fat .jar file and uploaded as Service binaries. The problem is, after a while, the server returns 504 Gateway Time-Out like in the attached screenshot. Any idea where to look at?

Thank you,
Victor.

Could you please upload your jar to either Google Drive or Dropbox and email the link to support@backendless.com? We’ll be happy to look into it.

Regards,
Mark

Sent already. Please let me know if there is anything else I can provide.

Thanks Mark!

Victor,

I looked into the jar you sent. The JAR you’re trying to deploy does not contain a custom service, instead you have there custom events. They may sound similar, but services and events are handled by different systems in Backendless, while both types are part of Custom Business Logic:

    Custom services - [url=https://backendless.com/documentation/api-engine/apieng_overview.htm]Backendless API Engine[/url] is the runtime environment which powers services. Services are created from java or php code. You deploy a class (as a part of the jar) which implements the IBackendlessService interface and all class' methods become individual endpoints. To deploy a service one would use the Hosted menu under Business Logic (this is what you were doing) Custom events - Backendless mBaaS is where events run. This is what you implemented. To deploy a custom event, you should use the deploy.bat/deploy.sh utility available in the CodeRunner SDK. For more info, please see this: https://backendless.com/documentation/business-logic/java/bl_production.htm
Hope this helps.

Regards,
Mark

Hi Mark,

I see. So what I’m trying to implement is Custom Events. This is where the External Host in Business Logic must be registered and approved I presume.

Thanks for the reply, Mark. Very helpful.

Victor.

Yes, for any external host your business logic needs to connect, you need to get an approval for it.

Regards,
Mark