发送推送通知时出现Worklight错误 [英] Worklight error when sending push notification

查看:124
本文介绍了发送推送通知时出现Worklight错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Worklight推送通知来发送iOS + Android应用程序的推送。

I am trying to use Worklight push notification to send push for a iOS+Android Application.

我在我的适配器中创建了submitNotification函数,当我调用它时,它说推送已成功发送,但实际上,我的设备没有收到推送。

I created the submitNotification function in my adapter, and when I invoke it, it says that the push was sent successfully, but in reality, I have no push received in my device.

当我看到日志时,我可以读到:

When I see the logs I can read:

Couldn't connect to APNS server
java.net.PlainSocketImpl.socketConnect(Native Method)
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
java.net.Socket.connect(Socket.java:529)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:570)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:371)
com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71)
com.notnoop.apns.internal.ApnsConnectionImpl.socket(ApnsConnectionImpl.java:133)
com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:160)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:52)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
com.worklight.integration.notification.apns.ApplicationConnection.sendNotification(ApplicationConnection.java:84)
com.worklight.integration.notification.apns.APNSMediator.sendNotification(APNSMediator.java:85)
com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
java.util.concurrent.FutureTask.run(FutureTask.java:138)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:680)

Couldn't send message com.notnoop.apns.EnhancedApnsNotification@96eee2c0                                  com.notnoop.apns.internal.ApnsConnectionImpl.socket(ApnsConnectionImpl.java:146)
com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:160)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:52)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
com.worklight.integration.notification.apns.ApplicationConnection.sendNotification(ApplicationConnection.java:84)
com.worklight.integration.notification.apns.APNSMediator.sendNotification(APNSMediator.java:85)
com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
java.util.concurrent.FutureTask.run(FutureTask.java:138)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:680)

然后

 Failed to send message com.notnoop.apns.EnhancedApnsNotification@96eee2c0... trying again

我的submitNotification函数:

My submitNotification function :

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

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

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

    WL.Server.notifyAllDevices(userSubscription, {
        badge : 1,
        activateButtonLabel : "Open",
        alert : notificationText
    });

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

我的代码有问题吗?或者使用我的网络?

Is there something wrong with my code? or with my Network ?

推荐答案

这最终是一个网络问题。

It was finally a network issue.

我们更改了防火墙配置,以允许访问Google和Apple推送服务器。
对于Apple Servers,您可以在以下地址找到更多详细信息: http://developer.apple.com/library/ios/#technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1- TNTAG41

We changed our Firewall configuration to allow access to Google and Apple push servers. For Apple Servers, you can find more details at this address : http://developer.apple.com/library/ios/#technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG41


将整个17.0.0.0/8地址块分配给Apple,因此您可以
指定防火墙规则中的范围。

the entire 17.0.0.0/8 address block is assigned to Apple, so you can specify that range in your firewall rules.

这篇关于发送推送通知时出现Worklight错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆