Topic
  • 4 replies
  • Latest Post - ‏2012-08-10T02:56:57Z by SystemAdmin
SystemAdmin
SystemAdmin
570 Posts

Pinned topic The connection to the server was unsuccessful

‏2012-06-19T09:22:14Z |
Hi,
My app don't have changes in native part, some days ago, my Android Environment deployed to my Google Nexus S works fine, after some web resources updated or settings changed (i.e. server port), now my Android app don't work, at app launch from emulator, I get an error 'The connection to the server was unsuccessful (file:///data/data/com.MyApp/files/www/default/MyApp.html), if I run it with my Google Nexus S, no errors raised but the screen don't response my submit request (it call worklight adapter to login), and nothing shown in worklight server log, I updated {showLogger: true}, but no log window shown in Android app.

And I want to check server address from Settings (even if I have checked the wlclient.properties and application-descriptor.xml) but I can't pop up options menu of the worklight app too, this is very strange, some days ago, it works fine and native application for Android is generated by Worklight Studio automatically, no changed made by manual.

I remembered that if my server port is wrong, during app launch, our app open an error dialog with 3 buttons, 3rd button can be used to change server address. now my login page shown correctly, after clicked login button, no any logs shown in worklight server.

I'm very strange what's wrong, I cannot get any logs. For comparison, The app works fine with an Android Browser, desktop browser, etc in previous mode.

Regards
Daniel
  • AntonAleksandrov
    AntonAleksandrov
    22 Posts

    Re: The connection to the server was unsuccessful

    ‏2012-06-20T07:29:33Z  
    First of all, remove showLogger:true property, it is not required on Android environment.
    edit your application-descriptor.xml file and make sure that the <worklightURL> element contains the valid URL that your Worklight server can be accessed at.
    Uninstall the old application from the device and build/deploy new one.
    In case application does not work try to open device's browser and browse to the Worklight server console (usually http://your-server:8080/console)
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: The connection to the server was unsuccessful

    ‏2012-07-04T01:06:40Z  
    First of all, remove showLogger:true property, it is not required on Android environment.
    edit your application-descriptor.xml file and make sure that the <worklightURL> element contains the valid URL that your Worklight server can be accessed at.
    Uninstall the old application from the device and build/deploy new one.
    In case application does not work try to open device's browser and browse to the Worklight server console (usually http://your-server:8080/console)
    Hi,

    Thanks to Anton,

    I verified server URL, I can run the app from preview mode (From Both PC browser and Mobile Browser), the server address is OK and worklight console is open too. I uninstall my app and delete folder /data/data/com.MyApp/

    with same codes, on Google Nexus S, login page shown, after input login name/password I clicked login button nothing captured into logcat (I put a WL.Logger.debug('xxx') at begin of JavaScript function), and log messages not captured into logcat in method wlCommonInit too.

    it seems that my JavaScript not run for potential error, but I can't get more errors except the following:
    I/Web Console(17687): Error in success callback: Network Status2 = TypeError: Cannot call method 'apply' of undefined at file:///data/data/com.MyApp/files/www/default/wlclient/js/phonegap.js:708.

    I don't changed any generated files by worklight studio, at line phonegap.js#708, it is a logging statement only, with above-mentioned error, I can't get call stack, and don't know where the error come from.

    run with emulator, it always give 'The connection to the server was unsuccessful, (file:///data/data/com.MyApp/files/www/default/MyApp.html)', then I updated my activity to following, but still timeout on emulator, my web pages don't refer to remote resources, all JS/CSS/Image packaged locally,

    public class MyApp extends WLDroidGap {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setIntegerProperty("loadUrlTimeoutValue", 30000);
    super.loadUrl(getWebMainFilePath(), 60000);
    }
    }

    Anybody get same error or know how to trace the actual root error of above-mentioned phonegap#708?

    background:
    1.My app uses adapter-based authentication with mode onDemand.
    2.Android source code is generated by worklight studio 4.2.1.1183 same as server's version, except setIntegerProperty() part.
    thanks for any hints.

    Daniel
  • DA81_Celine_Calista_Leong
    1 Post

    Re: The connection to the server was unsuccessful

    ‏2012-07-23T07:29:53Z  
    Hi,

    Thanks to Anton,

    I verified server URL, I can run the app from preview mode (From Both PC browser and Mobile Browser), the server address is OK and worklight console is open too. I uninstall my app and delete folder /data/data/com.MyApp/

    with same codes, on Google Nexus S, login page shown, after input login name/password I clicked login button nothing captured into logcat (I put a WL.Logger.debug('xxx') at begin of JavaScript function), and log messages not captured into logcat in method wlCommonInit too.

    it seems that my JavaScript not run for potential error, but I can't get more errors except the following:
    I/Web Console(17687): Error in success callback: Network Status2 = TypeError: Cannot call method 'apply' of undefined at file:///data/data/com.MyApp/files/www/default/wlclient/js/phonegap.js:708.

    I don't changed any generated files by worklight studio, at line phonegap.js#708, it is a logging statement only, with above-mentioned error, I can't get call stack, and don't know where the error come from.

    run with emulator, it always give 'The connection to the server was unsuccessful, (file:///data/data/com.MyApp/files/www/default/MyApp.html)', then I updated my activity to following, but still timeout on emulator, my web pages don't refer to remote resources, all JS/CSS/Image packaged locally,

    public class MyApp extends WLDroidGap {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setIntegerProperty("loadUrlTimeoutValue", 30000);
    super.loadUrl(getWebMainFilePath(), 60000);
    }
    }

    Anybody get same error or know how to trace the actual root error of above-mentioned phonegap#708?

    background:
    1.My app uses adapter-based authentication with mode onDemand.
    2.Android source code is generated by worklight studio 4.2.1.1183 same as server's version, except setIntegerProperty() part.
    thanks for any hints.

    Daniel
    Hi Daniel,

    I have been getting the same problem as you and after adding this line in the myApp.java file located in the src folder:

    super.setIntegerProperty("loadUrlTimeoutValue",60000);

    My app started working fine. Maybe increasing the timeout value will do the trick for you.

    Regards,
    Celine
  • SystemAdmin
    SystemAdmin
    570 Posts

    [Solved] Re: The connection to the server was unsuccessful

    ‏2012-08-10T02:56:57Z  
    Hi Daniel,

    I have been getting the same problem as you and after adding this line in the myApp.java file located in the src folder:

    super.setIntegerProperty("loadUrlTimeoutValue",60000);

    My app started working fine. Maybe increasing the timeout value will do the trick for you.

    Regards,
    Celine
    Hi,
    thanks all,

    I forget to remove second parameters from invocation to super.loadUrl(), remove it then ok.

    by the way, how to make the question as resolved?