简体   繁体   中英

Worklight - Push notification subscribe error after logout and being idle

Worklight 6.1.0.1 (Enterprise edition)

I have a Worklight hybrid app running on Android 4.4.2. It uses Adapter-based authentication for end-user login/logout and the user is subscribed to push notifications automatically after successful login and unsubscribed on successful logout. Additionally, I use the Worklight server timeout to timeout the user but I do not set a heartbeat interval. The server timeout is set to 3 minutes, for testing purposes.

Everything, including push notifications, works great until I follow these steps:

  1. Launch app
  2. Login as user (app subscribes user, succeeds)
  3. Logout
  4. Wait 4 minutes
  5. Login as user again (app subscribes user, fails)

These steps produce the following error in Logcat when the subscription is attempted for the second time:

04-16 17:52:43.200: E/NONE(1493): [http://ipaddress:10080/Mobile/apps/services/api/Student/android/notifications] failure. state: 500, response: Notification token unknown, subscribe to Push.StudentPushAlerts failed.

The Worklight Development Server Console produces this error:

[ERROR   ] FWLSE0020E: Ajax request exception: Notification token unknown, subscribe to Push.StudentPushAlerts failed. [project Mobile]
[ERROR   ] FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request  [project Mobile]Notification token unknown, subscribe to Push.StudentPushAlerts failed., User Identity {wl_authenticityRealm=null, AdapterAuthRealm=(name:12345678, loginModule:NonValidatingLoginModule), wl_remoteDisableRealm=(name:null, loginModule:NullLoginModule), wl_antiXSRFRealm=(name:cq6d0it2a32h7r57a7ineiaku8, loginModule:WLAntiXSRFLoginModule), wl_deviceAutoProvisioningRealm=null, wl_deviceNoProvisioningRealm=(name:d26bdbbb-ffeb-3070-bd5c-cfd407fb89cb, loginModule:WLDeviceNoProvisioningLoginModule), myserver=(name:1122a30c-992d-464d-a46a-880d20d03eee, loginModule:WeakDummy), wl_anonymousUserRealm=(name:1122a30c-992d-464d-a46a-880d20d03eee, loginModule:WeakDummy)}. [project Mobile] 
                                                                                                           com.worklight.common.log.filters.ErrorFilter

After much trial and error, I cannot get passed the error on the second subscribe if I wait between logins for a duration slightly greater than the server-side timeout value. In this case the server timeout is 3 minutes and I wait four minutes to produce the error consistently.

I attempted to reproduce this behavior in the IBM PushNotifications project sample by making some minor adjustments to mimick my application's flow, I had to add the timeout and a heartbeat to make it work. I did reproduce the error but the scenario is only similar to mine, so I suspect I am not seeing the full picture. However, the error is the same.

The IBM sample I am working with can be found here: modified IBM sample (GCM id/key removed from provided sample)

I can reproduce the error in my modified IBM sample by using the following steps:

  1. Launch app
  2. Login as user (onReadyToSubscribe runs, succeeds, close alert)
  3. Press the 'Subscribe' button (subscribe succeeds)
  4. Logout
  5. Wait 10 minutes
  6. Login as user again
  7. Press the 'Subscribe' button (subscribe fails)

Similarly to my project, these steps produce the following error in Logcat when the subscription is attempted for the second time:

04-16 15:54:06.952: E/NONE(7133): [http://ipaddress:10080/PushNotifications/apps/services/api/PushNotifications/android/notifications] failure. state: 500, response: Notification token unknown, subscribe to PushAdapter.PushEventSource failed.

The Worklight Development Server Console produces this error:

[ERROR   ] FWLSE0020E: Ajax request exception: Notification token unknown, subscribe to PushAdapter.PushEventSource failed. [project PushNotifications]
[ERROR   ] FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request  [project PushNotifications]Notification token unknown, subscribe to PushAdapter.PushEventSource failed., User Identity {wl_authenticityRealm=null, wl_remoteDisableRealm=(name:null, loginModule:NullLoginModule), wl_antiXSRFRealm=(name:u7kpkmov3r8259mvu8t0s0h6v6, loginModule:WLAntiXSRFLoginModule), PushAppRealm=(name:james, loginModule:PushAppLoginModule), wl_deviceAutoProvisioningRealm=null, wl_deviceNoProvisioningRealm=(name:0bd1dcc9-2d93-35a4-a216-1ff3b7ba908d, loginModule:WLDeviceNoProvisioningLoginModule), myserver=(name:james, loginModule:PushAppLoginModule), wl_anonymousUserRealm=null}. [project PushNotifications] 
                                                                                                           com.worklight.common.log.filters.ErrorFilter

If I don't wait between logins the subscriptions succeed everytime, even with switching users. My application's authenticationConfig.xml is:

<securityTests>

    <mobileSecurityTest name="Authentication-securityTest">
        <testDeviceId provisioningType="none"/>
        <testUser realm="AdapterAuthRealm"/>
    </mobileSecurityTest>
</securityTests> 

<realms>

    <realm loginModule="NonValidatingLoginModule" name="AdapterAuthRealm">
        <className>com.worklight.integration.auth.AdapterAuthenticator</className>
        <parameter name="login-function" value="Authentication.onAuthRequired"/>
        <parameter name="logout-function" value="Authentication.onLogout"/>
    </realm>

</realms>

<loginModules>
    <loginModule name="NonValidatingLoginModule">
        <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
    </loginModule>

</loginModules>

This appears to be related to an existing defect which is documented as APAR PI12693 . We have a fix available for this problem which can be obtained by opening a PMR (for customers with paid support).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM