PDA

View Full Version : App doesn't connect to server once deployed via phonegap



rhoward
2016-02-18, 22:44
Hi everyone,

I can't get mobile apps to connect to my server once built with phonegap! It's happening both on my own app and the Lianja Mobile Demo. The weird thing is, there's nothing wrong with the server since I can run the apps fine as web apps. If I put the IP of my server into the web browser I can access my apps and it works fine, but I can't seem to get them to connect to the server as actual apps on my phone built with phonegap. I put the base URL in the phonegap settings as 192.168.0.4:8001, is there any more to it than that? 192.168.0.4 being the internal IP of my dev machine with an instance of the cloud server running on it, of course.

I believe I've confirmed that the problem is in the connection with the server. I've spent the first half of the day debugging the mobile apps via chrome (following the steps at https://www.lianja.com/resources/blog/39-coding-tips/448-guide-to-debugging-android-lianja-mobile-apps-with-chrome) and when my app calls Lianja.evaluate() in its init delegate the evaluate fails. Going through the calling functions to the error being thrown, it appears that no data is ever returned to the client from the call that evaluates the function on the server (the function is valid and always returns at least something). The Lianja Mobile Demo on the other hand breaks on attempting the GET calls to load the tables saying page not found. Also login functionality is broken in both apps.

Finally, when I look at the server logs, it doesn't mention anything about a client connecting during the time I was running the mobile apps. They only mention a few things that seem to be server setup, then say "waiting for client connection on port 8001". The only time it mentioned any requests was when I ran the apps in my browser instead.

Since the apps connect to the server in a browser but not as a built phonegap app, I believe I've done something wrong in my deployment. Is there anything extra that you need to do to get a phonegap app to connect to a cloud server apart from setting the base URL?

Thanks,
Ryan

yvonne.milne
2016-02-19, 05:29
Hi Ryan,

When you say they work in the browser - do you mean from the browser on the same phone?

Also, for the Base URL in the App Options for the PhoneGap Build, did you put the full URL?

http://192.168.0.4:8001

Thanks,

Yvonne

rhoward
2016-02-21, 20:32
Hi Yvonne,

Putting http:// at the start of the URL worked. With the Lianja Mobile Demo app, anyway. With mine it just shows a blank grey screen now but I'm willing to bet that's a bug in my app instead of an issue connecting to the database. Which I can go through debugging now that I can connect.

Thanks!