Topic
  • 15 replies
  • Latest Post - ‏2012-06-06T20:10:22Z by SystemAdmin
SystemAdmin
SystemAdmin
570 Posts

Pinned topic [Solved] Error getting while the appliation starts

‏2012-03-27T06:11:29Z |
Hi.

I'm trying to run a simple application with worklight 4.2.2.

I'm testing it in an Android Environment using the worklight console and also an Android emulator.

The problem I'm facing is, After successful deployement, The appliaction starts on the android emulator and following popup occurs on the emulator's screen
The connection to the server was unsuccessful. (file:///data/data/com.HelloDojoApp/files/www/default/HelloDojoApp.html)

And before getting this popup, I am getting following statement in logcat logs..

03-26 22:24:17.334: D/WLDroidGap(226): Started copying files to local storage...
03-26 22:24:27.945: D/WLDroidGap(226): Finished copying files to local storage...
03-26 22:24:27.997: D/(226): unable to unlink '/data/data/com.HelloDojoApp/shared_prefs/WLPrefs.xml.bak': No such file or directory (errno=2)
03-26 22:24:28.076: D/DroidGap(226): DroidGap.loadUrl(file:///data/data/com.HelloDojoApp/files/www/skinLoader.html)
03-26 22:24:28.085: D/DroidGap(226): DroidGap: url=file:///data/data/com.HelloDojoApp/files/www/skinLoader.html baseUrl=file:///data/data/com.HelloDojoApp/files/www/
03-26 22:24:28.808: D/dalvikvm(226): GC freed 2252 objects / 454312 bytes in 522ms
03-26 22:24:28.984: D/SoftKeyboardDetect(226): Ignore this event
03-26 22:24:36.029: D/DroidGap(226): DroidGap.loadUrl(file:///data/data/com.HelloDojoApp/files/www/default/HelloDojoApp.html)
03-26 22:24:36.034: D/DroidGap(226): DroidGap: url=file:///data/data/com.HelloDojoApp/files/www/default/HelloDojoApp.html baseUrl=file:///data/data/com.HelloDojoApp/files/www/
03-26 22:24:37.406: D/dalvikvm(226): GC freed 3801 objects / 356296 bytes in 362ms
03-26 22:24:56.088: E/DroidGap(226): DroidGap: TIMEOUT ERROR! - calling webViewClient
03-26 22:24:56.135: D/DroidGap(226): DroidGap: GapViewClient.onReceivedError: Error code=-6 Description=The connection to the server was unsuccessful. URL=file:///data/data/com.HelloDojoApp/files/www/default/HelloDojoApp.html

The logcat export has been attached for reference.

Thanks.
  • IdanAdar
    IdanAdar
    288 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-03-27T06:27:52Z  
    Connection timeout usually happen with the Android emulator when the IP address is not correctly set for WorklightRootURL.
    Try setting your actual local IP address, for example 192.168.53.27.
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-03-28T19:19:39Z  
    Hi Idan,

    I changed the worklightRootURL to my actual local IP Address.

    <worklightRootURL>http://192.168.1.2:8080</worklightRootURL>

    But still the same error is occurring on startup each time I run that application.
  • IdanAdar
    IdanAdar
    288 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-03-28T20:49:42Z  
    Can you attach your project?
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-03-29T08:44:52Z  
    Hi Idan

    Please find the project in zip format ("Application.zip") attached with this reply.

    Thanks.
  • IdanAdar
    IdanAdar
    288 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-03-29T10:22:03Z  
    Hi,

    I took your project as-is and simply changed the IP address in worklightRootURL to that of my own and I have managed to successfully launch the application on my Android emulator and have it connect to my local Worklight Server.

    Only issue I can think of is still that of the IP address you are using.
    Do you perhaps have 2 networks that you are connected to?

    From the error messages you have pasted the following seems unlikely,
    But, if you are using ADT v17, consider downgrading both the SDK and ADT to v16 and see if anything changes, however I do believe it is due to an IP address issue...
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-03-29T17:57:58Z  
    Hi Idan,

    I was on single network that I verified using ipconfig command.

    to make sure the i should test it locally, I got disconnected from the network so that I can manage to run the application and connect it to worklight server using 127.0.0.1. At that time I was getting

    03-29 01:38:53.768: E/HelloWorklightDojoApp(602): Client init failed. Connection to the service is not available.

    the emulator image has been attached for your reference which contains the detail of app diagnostic.

    Thanks.
  • IdanAdar
    IdanAdar
    288 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-03-29T18:48:14Z  
    Can you load Worklight Console (typicall localhost:8080/console) from the emulator's browser?
    If you can't load it, then the emulator simply can't connect to anything... in this situation you can try creating another AVD and see if that helps.
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-04-01T18:45:30Z  
    Hi Idan,

    I tried to load from emulator's browser locally and it was not loaded.
    so I connected to network again and tried to load the worklight console and it was successfully loaded.

    After that I deployed the application again in android emulator and analyzed the logs from logcat. Again i got the same : DroidGap: TIMEOUT ERROR! - calling webViewClient" in the emulator.

    I am attaching logs of logcat which is showing that request and response were properly exchanged between application deployed in android emulator and worklight server that means the connection is establish between emulator and worklight server.

    04-01 23:37:43.019: D/dalvikvm(379): GC freed 949 objects / 68200 bytes in 258ms
    04-01 23:37:43.429: W/dalvikvm(379): VFY: unable to find class referenced in signature (Landroid/webkit/ConsoleMessage;)
    04-01 23:37:43.440: I/dalvikvm(379): Could not find method android.webkit.ConsoleMessage.message, referenced from method com.phonegap.DroidGap$GapClient.onConsoleMessage
    04-01 23:37:43.440: W/dalvikvm(379): VFY: unable to resolve virtual method 306: Landroid/webkit/ConsoleMessage;.message ()Ljava/lang/String;
    04-01 23:37:43.440: D/dalvikvm(379): VFY: replacing opcode 0x6e at 0x0002
    04-01 23:37:43.453: D/dalvikvm(379): Making a copy of Lcom/phonegap/DroidGap$GapClient;.onConsoleMessage code (44 bytes)
    04-01 23:37:43.739: D/WLDroidGap(379): no need to check web resource integrity
    04-01 23:37:45.809: D/dalvikvm(379): GC freed 2419 objects / 229912 bytes in 268ms
    04-01 23:38:03.959: E/DroidGap(379): DroidGap: TIMEOUT ERROR! - calling webViewClient
    04-01 23:38:09.580: D/xApp(379): wlclient init started
    04-01 23:38:10.879: D/xApp(379): Read cookies: null
    04-01 23:38:11.109: D/xApp(379): CookieMgr read cookies: {}
    04-01 23:38:16.659: D/xApp(379): Request http://192.168.1.2:8080/apps/services/api/xApp/android/0/authentication
    04-01 23:38:31.739: D/xApp(379): Storing cookies: ({"WL_PERSISTENT_COOKIE":"e400ad87-6543-41ae-8205-6c7c7122b035"})
    04-01 23:38:31.819: D/xApp(379): Storing cookies: ({"WL_PERSISTENT_COOKIE":"e400ad87-6543-41ae-8205-6c7c7122b035","01-Apr-2013 18:26:06 GMT; Path":"/apps/services"})
    04-01 23:38:31.859: D/xApp(379): response http://192.168.1.2:8080/apps/services/api/xApp/android/0/authentication success: /*-secure-
    04-01 23:38:31.859: D/xApp(379): {"success":"success"}*/
    04-01 23:38:32.239: D/xApp(379): Request http://192.168.1.2:8080/apps/services/api/xApp/android/0/init
    04-01 23:38:32.709: D/dalvikvm(379): GC freed 4949 objects / 744040 bytes in 383ms
    04-01 23:38:33.512: D/xApp(379): response http://192.168.1.2:8080/apps/services/api/xApp/android/0/init success: /*-secure-
    04-01 23:38:33.512: D/xApp(379): {"userPrefs":{},"gadgetProps":{"IID":"6","directUpdate":{"availableSkins":,"checksum":2357008051,"updateSize":229279},"ENVIRONMENT":"android"},"userInfo":{"PersistentCookie":{"userName":"e400ad87-6543-41ae-8205-6c7c7122b035","isUserAuthenticated":"1","loginName":"e400ad87-6543-41ae-8205-6c7c7122b035"},"SampleAppRealm":{"isUserAuthenticated":"0"},"AdminResourceRealm":{"isUserAuthenticated":"0"}}}*/
    04-01 23:38:33.850: D/xApp(379): wlclient connect success
    04-01 23:38:36.469: D/xApp(379): before: app init onSuccess
    04-01 23:38:36.909: D/xApp(379): after: app init onSuccess
    04-01 23:38:36.989: D/xApp(379): wlclient init success

    From the last approx last 15 lines it is clear that the interaction is proper and that IP address is resolved then in this case why the application is behaving in error prone manner.

    Thanks.
  • IdanAdar
    IdanAdar
    288 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-04-02T04:59:52Z  
    That's a good question, as the attached project did load find for me... which leads to be believe it might be due to environment differences.
    Can you elaborate on those of yours? Android SDK, ADT, Eclipse, Worklight Server and Studio build version, OS, etc...

    Also, the second log you attached - where you did manage to at least connect to the server is from a different application than in the original log.
    The same happens to you with different applications, where here it does not. Hm.
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-04-02T17:46:04Z  
    Hi Idan,

    This configuration is running on Windows XP with Service Pack 3.

    ADT 17.0.0.v201203161636-291853
    Android Emulator V2.1
    Eclipse Version: 3.7.2.v20120207-1839-9gF7UHPDFxGjd-PqDr2jX_4yKaumkoHTz04_q-q
    Worklight Server 4.2.2.1283
    Worklight Studio Build Version 4.2.2

    Besides that I also ran the same application on Android Emulator V4.0.3 (Rev. 2) with the same configuration.

    The application is same except the name is different. Here also the application is managing to connect to server, however I noticed 2 extra lines in this log which appears just before i get the error "DroidGap: TIMEOUT ERROR! - calling webViewClient".

    04-02 22:26:08.358: I/SqliteDatabaseCpp(1816): sqlite returned: error code = 14, msg = cannot open file at line 27701 of 8609a15dfa, db=/data/data/com.xApp/databases/webview.db
    04-02 22:26:08.358: I/SqliteDatabaseCpp(1816): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27701 - "" errno=2 path=/CachedGeoposition.db, db=/data/data/com.xApp/databases/webview.db

    Does these lines provide any clue on the issue. The cmplete log file (contains logs from logcat while running on Android emulator 4.0.3 ) is attached with this post.

    Thanks.
  • IdanAdar
    IdanAdar
    288 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-04-02T19:32:43Z  
    From a first glanse, not so much. I will run it through our developers.

    Can you create a new application that is not utilizing Dojo?

    We are also about to release a patch forWorklight 4.2.1, 4.2.2 with a fix for ADT17. You can try that too, though I'm not seeing the same errors that are typical for that bug.
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-04-11T18:55:44Z  
    Hi Idan,
    I have got this issue solved.
    This issue was not specific to IP Address, Instead there was some time out issue.
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-05-10T20:39:34Z  
    Hi Abhishek,

    Can you tell me exactly what timeout issue you were having? I am having the same problem as you were and my System specifications are similar to yours too.

    Thanks,
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-05-22T07:43:14Z  
    Hi Abhishek,
    I have a same problem with you. Can you tell me how to solve it?
    Thanks,
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Error getting while the appliation starts

    ‏2012-06-06T20:10:22Z  
    Here's the two-step work-around that solved the problem for me:

    1. As discussed previously, edit the application-descriptor.xml and change the worklightRootURL to your local IP address, such as:

    
    <worklightRootURL>http:
    //192.168.1.126:8080</worklightRootURL>
    


    2. Increase the timeout by editing the Android java file that implements the WLDroidGap...

    File: YourProject -> apps -> YourApp -> android -> native -> src -> com -> YourApp -> YourApp.java

    Insert a line to a call to setIntegerProperty to increase the loadUrlTimeoutValue timeout:

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