-1

我已经使用Push on Dev服务器工作过应用程序。当我从应用程序部署我的生产环境和触发推送发送事件项目,我得到错误Worklight推送不能在生产环境中工作

"An error was encountered while processing the request from the application.".

请帮我解决这个问题。

PushAdapter.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<wl:adapter xmlns:wl="http://www.worklight.com/integration" xmlns:http="http://www.worklight.com/integration/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PushAdapter"> 

    <displayName>PushAdapter</displayName> 
    <description>PushAdapter</description> 
    <connectivity> 
     <connectionPolicy xsi:type="http:HTTPConnectionPolicyType"> 
      <protocol>http</protocol> 
      <domain>cnn.com</domain> 
      <port>80</port>   
     </connectionPolicy> 
     <loadConstraints maxConcurrentConnectionsPerNode="2"/> 
    </connectivity> 
    <procedure name="submitNotification" securityTest="wl_unprotected"/> 
</wl:adapter> 

PushAdapter-impl.js

WL.Server.createEventSource({ 
    name: 'PushEventSource', 
    onDeviceSubscribe: 'deviceSubscribeFunc', 
    onDeviceUnsubscribe: 'deviceUnsubscribeFunc', 
    securityTest: 'AngularStarter-strong-mobile-securityTest' 
}); 

function deviceSubscribeFunc(userSubscription, deviceSubscription){ 
    WL.Logger.debug(">> deviceSubscribeFunc"); 
    WL.Logger.debug(userSubscription); 
    WL.Logger.debug(deviceSubscription); 
} 

function deviceUnsubscribeFunc(userSubscription, deviceSubscription){ 
    WL.Logger.debug(">> deviceUnsubscribeFunc"); 
    WL.Logger.debug(userSubscription); 
    WL.Logger.debug(deviceSubscription); 
} 

function submitNotification(userId, notificationText) { 
    var userSubscription = WL.Server.getUserNotificationSubscription('PushAdapter.PushEventSource', userId); 

    if (userSubscription == null) { 
     return { result: "No subscription found for user :: " + userId }; 
    } 

    var badgeDigit = 1, 
     notification = WL.Server.createDefaultNotification(notificationText, badgeDigit, {custom: "data"}); 

    WL.Logger.debug("submitNotification >> userId :: " + userId + ", text :: " + notificationText); 
    WL.Server.notifyAllDevices(userSubscription, notification); 

    return { 
     result: "Notification sent to user :: " + userId 
    }; 
} 

logcat的信息

10-18 20:52:41.550: D/NONE(1819): Request [http://server/context/apps/services/../../invoke] 
10-18 20:52:41.601: D/HttpPostRequestSender(1819): HttpPostRequestSender.run in HttpPostRequestSender.java:46 :: Sending request http://server/context/invoke 
10-18 20:52:41.661: D/dalvikvm(1819): GC_FOR_ALLOC freed 674K, 27% free 10121K/13800K, paused 18ms, total 18ms 

10-18 20:52:41.711: D/NONE(1819): Request [http://server/context/apps/services/api/ProjectName/android/notifications] 
10-18 20:52:41.751: D/HttpPostRequestSender(1819): HttpPostRequestSender.run in HttpPostRequestSender.java:46 :: Sending request http://server/context/apps/services/api/ProjectName/android/notifications 
10-18 20:52:41.771: D/push(1819): Push.dispatch in Push.java:350 :: Push.dispatch(): method=WL.Client.Push.__onmessage 
10-18 20:52:41.771: D/push(1819): Push.dispatch in Push.java:359 :: Javascript script requests dispatching to WL.Client.Push.__onmessage 
10-18 20:52:41.791: D/dalvikvm(1819): GC_FOR_ALLOC freed 510K, 27% free 10116K/13800K, paused 18ms, total 18ms 
10-18 20:52:41.801: D/NONE(1819): Request [http://server/context/apps/services/api/ProjectName/android/login] 

10-18 20:52:41.831: D/HttpPostRequestSender(1819): HttpPostRequestSender.run in HttpPostRequestSender.java:46 :: Sending request http://server/context/apps/services/api/ProjectName/android/login 
10-18 20:52:41.851: D/NONE(1819): Request [http://server/context/apps/services/api/ProjectName/android/query] 
10-18 20:52:41.881: D/dalvikvm(1819): GC_FOR_ALLOC freed 496K, 27% free 10130K/13800K, paused 18ms, total 18ms 

10-18 20:52:41.901: D/NONE(1819): Clearing notification subscriptions. 
10-18 20:52:41.921: D/dalvikvm(1819): GC_FOR_ALLOC freed 162K, 25% free 10474K/13800K, paused 19ms, total 19ms 
10-18 20:52:41.921: D/GCMRegistrar(1819): resetting backoff for com.ProjectName 
10-18 20:52:41.921: V/GCMRegistrar(1819): Registering app com.ProjectName of senders 1010830861176 

10-18 20:52:41.921: D/NONE(1819): Clearing tag notification subscriptions. 
10-18 20:52:41.931: D/NONE(1819): Send new server notification token id. 
10-18 20:52:41.931: D/NONE(1819): Updating tag notification subscriptions. 
10-18 20:52:41.941: D/NONE(1819): response [http://server/context/apps/services/api/ProjectName/android/login] success: /*-secure- 
10-18 20:52:41.941: D/NONE(1819): {"wl_directUpdateRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null"},"wl_authenticityRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null},"AdapterAuthRealm":{"userId":"demo","isUserAuthenticated":1,"displayName":"demo"},"WL-Authentication-Success":{"AdapterAuthRealm":{"userId":"demo","isUserAuthenticated":1,"displayName":"demo"}},"wl_remoteDisableRealm":{"userId":"null","attributes":{},"isUserAuthenticated":1,"displayName":"null"},"notificationSubscriptionState":{"tags":["Push.ALL"],"eventSources":[],"token":"APA91bFNbZIblAxjd1ls6ldN_LbwU77-nM3R9LtP7cxAXcU1q4WCM1tthy6p6v7YLWmHqDwC3nNg4TNDkCm9ZVOtJCQGIRySBMf1gWq3nUdLFmX9BSIItxas5l7cYcGMvycPF1cxt58M_s29XxVY9uD7FbDM3IJNGA"},"wl_antiXSRFRealm":{"userId":"nbtk4iv001kpt5rvl5dra6q07v","attributes":{},"isUserAuthenticated":1,"displayName":"nbtk4iv001kpt5rvl5dra6q07v"},"wl_deviceAutoProvisioningRealm":{"userId":null,"attributes":{},"isUserAuthenticated":0,"displayName":null},"wl_deviceNoProvisioningRealm":{"userId":"52318dd3-900b-3a85-8752-fbf53cfec056","attributes":{"mobileClientData":"[email protected]"},"isUserAuthenticated":1,"displayName":"52318dd3-900b-3a85-8752-fbf53cfec056"},"myserver":{"userId":"a20252a0-954f-46ae-bb55-2984c8fae7b6","attributes":{},"isUserAuthenticated":1,"displayName":"a20252a0-954f-46ae-bb55-2984c8fae7b6"},"wl_anonymousUserRealm":{"userId":"a20252a0-954f-46ae-bb55-2984c8fae7b6","attributes":{},"isUserAuthenticated":1,"displayName":"a20252a0-954f-46ae-bb55-2984c8fae7b6"}}*/ 

10-18 20:52:41.941: D/NONE(1819): defaultOptions:onSuccess 
10-18 20:52:41.981: D/HttpPostRequestSender(1819): HttpPostRequestSender.run in HttpPostRequestSender.java:46 :: Sending request http://server/context/apps/services/api/ProjectName/android/query 
10-18 20:52:42.031: D/dalvikvm(1819): GC_FOR_ALLOC freed 401K, 24% free 10584K/13800K, paused 18ms, total 19ms 

10-18 20:52:42.171: V/GCMBroadcastReceiver(1819): onReceive: com.google.android.c2dm.intent.REGISTRATION 
10-18 20:52:42.171: V/GCMBroadcastReceiver(1819): GCM IntentService class: com.ProjectName.GCMIntentService 
10-18 20:52:42.171: V/GCMBaseIntentService(1819): Acquiring wakelock 
10-18 20:52:42.181: V/GCMBaseIntentService(1819): Intent service name: GCMIntentService-DynamicSenderIds-2 
10-18 20:52:42.181: D/GCMBaseIntentService(1819): handleRegistration: registrationId = APA91bFNbZIblAxjd1ls6ldN_LbwU77-nM3R9LtP7cxAXcU1q4WCM1tthy6p6v7YLWmHqDwC3nNg4TNDkCm9ZVOtJCQGIRySBMf1gWq3nUdLFmX9BSIItxas5l7cYcGMvycPF1cxt58M_s29XxVY9uD7FbDM3IJNGA, error = null, unregistered = null 
10-18 20:52:42.181: D/GCMRegistrar(1819): resetting backoff for com.ProjectName 
10-18 20:52:42.181: V/GCMRegistrar(1819): Saving regId on app version 20 
10-18 20:52:42.191: D/GCMIntentService(1819): GCMIntentService.onRegistered in GCMIntentService.java:75 :: WLGCMIntentService: Registered at the GCM server with registration id APA91bFNbZIblAxjd1ls6ldN_LbwU77-nM3R9LtP7cxAXcU1q4WCM1tthy6p6v7YLWmHqDwC3nNg4TNDkCm9ZVOtJCQGIRySBMf1gWq3nUdLFmX9BSIItxas5l7cYcGMvycPF1cxt58M_s29XxVY9uD7FbDM3IJNGA 
10-18 20:52:42.191: V/GCMBaseIntentService(1819): Releasing wakelock 

10-18 20:52:42.251: D/CordovaWebViewClient(1819): onPageFinished(file:///android_asset/www/default/index.html#/inbox/index) 
10-18 20:52:42.251: D/CordovaActivity(1819): onMessage(onPageFinished,file:///android_asset/www/default/index.html#/inbox/index) 
10-18 20:52:42.321: D/NONE(1819): response [http://server/context/apps/services/api/ProjectName/android/query] success: /*-secure- 
10-18 20:52:42.321: D/NONE(1819): {"isSuccessful":true,"result":"No subscription found for user :: null"}*/ 
10-18 20:52:42.321: W/NONE(1819): Event source callback is already registered with alias: myPush 
10-18 20:52:44.323: D/NONE(1819): Piggybacking event transmission 
10-18 20:52:44.333: D/NONE(1819): Flush called 

服务器日志

https://www.dropbox.com/s/2j0efjcxmbw0mfg/52318dd3-900b-3a85-8752-fbf53cfec056-logs-3.json?dl=0

+0

从LogCat添加服务器日志和日志。 – 2014-10-18 02:29:54

+0

- 已在更新中添加LogCat和服务器日志。请帮助解决问题。 – alexeybondarenko 2014-10-18 19:11:29

+0

您提到的错误不在logcat中,也不在服务器日志中,这不是真正来自worklight的服务器日志。你在哪里得到这个错误? – 2014-10-24 06:11:00

回答

0

在PushAdapter-impl.js/submitNotification,你发送通知给其用户id传递中作为参数传递给适配器(用户ID)订阅用户。

检查logcat日志 - 该用户的订阅在Worklight中不存在 - 您可能从未从应用程序调用WL.Client.subscribe()。

相关问题