Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
8 replies Latest Post - ‏2012-10-14T08:09:51Z by VasiliyBorodin
VasiliyBorodin
VasiliyBorodin
7 Posts
ACCEPTED ANSWER

Pinned topic The connection to the server was unsuccessful

‏2012-10-11T08:44:42Z |
Hi!
I am newbie in mobile development. I create simple app with jQuery. In browser it is works, but in emulator of android i receive the error "The connection to the server was unsuccessful. (file:///data......html)"
I am doesnt create any connection, i wrote only html-code.
In my android device i receive error like error in emulator.

Tell me please what i must do with this error?
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: The connection to the server was unsuccessful

    ‏2012-10-11T09:23:14Z  in response to VasiliyBorodin
    Worklight-based applications by default connect to the Worklight Server upon launch.
    • Make sure the Worklight Server is running (are you running the Developer Edition of IBM Worklight?)
    • Make sure you have Internet connection available
    • Make sure to put your IP address in application-descriptor.xml, in the worklightServerRootURL property.

    Have you following the training materials? These explain to you in detail how Worklight works...
    https://www.ibm.com/developerworks/mobile/worklight/getting-started/index.html

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
  • Capstan
    Capstan
    18 Posts
    ACCEPTED ANSWER

    Re: The connection to the server was unsuccessful

    ‏2012-10-11T16:51:50Z  in response to VasiliyBorodin
    It took me a while to figure this out too. By default Worklight applications attempt to "phone home" to the Worklight server you designate in the application-descriptor.xml file. One thing this does for you is to have the app automatically check to see if there is an upgraded version available, and if so a dialog pops up that lets you opt to download it and install it. Also you presumably get access to other server features.

    If you don't want this to happen you can edit initOptions.js and set;
    var wlInitOptions = {
    connectOnStartup : false
    };
    • christianIBM
      christianIBM
      78 Posts
      ACCEPTED ANSWER

      Re: The connection to the server was unsuccessful

      ‏2012-10-12T20:59:57Z  in response to Capstan
      Capstan, this is true. Heres some more info from the WL docs on 'connectOnStartup' :

      connectOnStartup:
      Whether to connect to the IBM Worklight Server or not. Default is true. You may set this parameter to false when your app does not retrieve any corporate data on startup.
      Note, though, that any server features such as Remote Disable or Direct Update are only available when the app connects to the server.

      -Worklight Development Team, iOS-Christian Linares
      • christianIBM
        christianIBM
        78 Posts
        ACCEPTED ANSWER

        Re: The connection to the server was unsuccessful

        ‏2012-10-12T21:00:39Z  in response to christianIBM
        So by setting to false, your biggest loss is Remote Disable and Direct Update

        -Worklight Development Team, iOS-Christian Linares
  • VasiliyBorodin
    VasiliyBorodin
    7 Posts
    ACCEPTED ANSWER

    Re: The connection to the server was unsuccessful

    ‏2012-10-13T07:03:23Z  in response to VasiliyBorodin
    I am starting my app using <body onload="WL.Client.init({connectOnStartup:false})" id="content" style="display:none;">
    In WL Server (localhost:8080) all is good, in my mobile phone (LG GW 620) too, but in emulator of Android OS i have this problem =( But if i delete line where i including jquery - the app not give the error. Magic? I am using last version of jquery and jquery mobile...
    I can ignore this problem if it may have no effect on the real device.

    Now i have another problem =)
    I create HTTP Adaptor and use it to receave some data from my server in WEB. In WL Server - all is ok! But if i start my app in mobile phone it not receave data =( Phone have enternet connection, i did not change rights of the application (now they are default)
  • VasiliyBorodin
    VasiliyBorodin
    7 Posts
    ACCEPTED ANSWER

    Re: The connection to the server was unsuccessful

    ‏2012-10-13T13:30:21Z  in response to VasiliyBorodin
    How i can find the cause of the behavior of the application?
    And may be Worklight have function list or something like this base: http://www.php.net/manual/en/function.echo.php
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: The connection to the server was unsuccessful

    ‏2012-10-14T05:48:34Z  in response to VasiliyBorodin
    Can you please open a separate thread for your adapter issue?
    It is hard to maintain order otherwise. Thanks.

    As for the connection error in the adapter,
    • Did you transfer the updated app to the emulator? (so that it too will have the connectOnStartup:false property)
    • What Android OS version did you choose for the AVD?

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform

    Message was edited by: IdanAdar
  • VasiliyBorodin
    VasiliyBorodin
    7 Posts
    ACCEPTED ANSWER

    Re: The connection to the server was unsuccessful

    ‏2012-10-14T08:09:51Z  in response to VasiliyBorodin
    I start a new thread with quations about adaptor:
    https://www.ibm.com/developerworks/forums/thread.jspa?threadID=458644