Topic
  • 3 replies
  • Latest Post - ‏2012-11-13T10:26:45Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts

Pinned topic About WL.Events when using heartbeat

‏2012-10-12T10:14:05Z |
I am trying to exercise module (Getting started with IBM Worklight) in following page.
http://www.ibm.com/developerworks/mobile/worklight/getting-started/index.html

In "Module 07.7 - Offline Access" , WL.Events are introduced.
http://public.dhe.ibm.com/ibmdl/export/pub/software/mobile-solutions/worklight/docs/Module_07_7_-_Offline_Access.pdf

I think WL.Events.WORKLIGHT_IS_CONNECTED/WORKLIGHT_IS_DISCONNECTED should be fired when connection status changed from/to online/offline.
WL.Events was fired when using WL.Client.invokeProcedure and WL.Client.connect,but it was not fired when change of status was detected by Worklight heartbeat.

I set heartbeat interval to 5 sec using WL.Client.setHeartBeatInterval(5).

<<received messages>>(in web browser debug console)
  • online ---
response [/apps/services/api/OfflineApp/android/heartbeat] success: wlgap.android.js:1285
Request [/apps/services/api/OfflineApp/android/heartbeat] wlgap.android.js:1285

  • offline ---
POST http://localhost:8080/apps/services/api/OfflineApp/android/heartbeat 404 (ProxyServlet: /apps/services/api/OfflineApp/android/heartbeat) base.js:889
[/apps/services/api/OfflineApp/android/heartbeat] failure. state: 404, response: The server was unable to process the request from the application. Please try again later.
====

Are WL.Evnets (WORKLIGHT_IS_CONNECTED/WORKLIGHT_IS_DISCONNECTED) fired when using heartbeat ?
My Environment
Windows XP
Eclipse : 3.7.2
WorklightStudioPlugin: 5.0.2.407-devloper-edition
Thank you.
  • IdanAdar
    IdanAdar
    741 Posts

    Re: About WL.Events when using heartbeat

    ‏2012-10-12T12:51:41Z  
    If you will quit Eclipse you will not get the 404 error.
    This happens because despite stopping the server, Jetty might still be running in the Eclipse instance. Quitting Eclipse will sever the connection completely and you will then notice how the exercise takes place as it should. I believe we have an open defect about this.

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: About WL.Events when using heartbeat

    ‏2012-10-15T04:18:58Z  
    • IdanAdar
    • ‏2012-10-12T12:49:30Z
    If you will quit Eclipse you will not get the 404 error.
    This happens because despite stopping the server, Jetty might still be running in the Eclipse instance. Quitting Eclipse will sever the connection completely and you will then notice how the exercise takes place as it should. I believe we have an open defect about this.

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
    Hello, Idan Adar.

    Thank you for the advice.

    Jetty is fine in my environment.
    When I quit Eclipse, Jetty also stop and then I get Error 404 from web browser.

    After confirming the online response message, I stopped the Worklight Server.
    After 5 sec, I confirmed the offline message (heartbeat 404) and could not access Worklight Console ( http://localhost:8080/console ).
    I'd like to handle WL.Event of offline(WL.Events.WORKLIGHT_IS_DISCONNECTED) here.
    but I could not handle it...

    I think the following code is related to this behavior.

    <<in wlclient.js>>
    WL.Client.sendHeartBeat = function() {
    new WLJSX.Ajax.WLRequest(REQ_PATH_HEART_BEAT, {
    onSuccess : function() {
    },
    onFailure : function() {
    },
    timeout : getAppProp(WL.AppProp.WLCLIENT_TIMEOUT_IN_MILLIS)
    });
    }

    onSuccess and onFailure is overrided in sendHeartBeat so I could not handle WL.Event.
    This is Correct ?

    If correct, is there any idea to handle WL.Event while heartbeat ?
    Regards,
    Motokazu Nishimura
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: About WL.Events when using heartbeat

    ‏2012-11-13T10:26:45Z  
    • IdanAdar
    • ‏2012-10-12T12:49:30Z
    If you will quit Eclipse you will not get the 404 error.
    This happens because despite stopping the server, Jetty might still be running in the Eclipse instance. Quitting Eclipse will sever the connection completely and you will then notice how the exercise takes place as it should. I believe we have an open defect about this.

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
    Hello, Idan Adar.

    I tried again with Quitting Eclipse.
    The event handler (WL.Events.WORKLIGHT_IS_DISCONNECTED) was triggered while heartbeat.
    Jetty was not running.

    thank you.
    Regards,
    Motokazu Nishimura