0

这个问题我纠结了好久,希望有大神帮忙?我有一些 JavaPNS 代码在从本地计算机运行时可以很好地推送到我的设备,但是,当我将该代码复制到我的服务器时,一切运行正常,没有错误,但我从未在我的设备上收到警报?在检查了来自我的服务器的日志与我的本地机器相比之后,我注意到我从来没有在我的服务器上收到刷新消息,我使用的是 JavaPNS 队列,有 30 个线程。在这两种情况下,本地盒子和服务器,我发送的警报都少于 30 个。

public class PushWorker 
{
private PushQueue queue = null;

public PushWorker(File keystore, String password, boolean production) throws KeystoreException
{
    BasicConfigurator.configure();
    int threads = 30;
    this.queue = Push.queue(keystore, password, production, threads);
    queue.start();
}

public void push(String message, String sound, String token, String eventId) throws JSONException
{
    BasicDevice bd = new BasicDevice();
    bd.setToken(token);

    PushNotificationPayload payload = PushNotificationPayload.complex();
    payload.addAlert(message);
    payload.addSound(sound);
    payload.addCustomDictionary("eid", eventId);

    push(payload, bd);
}

private void push(Payload payload, Device device)
{
    queue.add(payload, device);
}
}

----BELOW 是来自我本地邮箱的刷新消息-------------

4872 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.notification.PushNotificationManager  - Flushing
4872 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.notification.PushNotificationManager  - At this point, the entire 139-bytes message has been streamed out successfully through the SSL connection
4872 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.notification.PushNotificationManager  - Notification sent on first attempt

我可以以某种方式从队列中强制刷新吗?

----------------------BELOW 是服务器 JavaPNS 日志记录---------- -

0 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocketFactory
16 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocketFactory
49 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
49 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
177 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.notification.PushNotificationManager  - Initialized Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195]: 5117f31e[SSL_NULL_WITH_NULL_NULL: Socket[addr=gateway.sandbox.push.apple.com/17.172.233.65,port=2195,localport=56015]]
...
...

DEBUG javapns.notification.Payload  - Adding alert [blah, blah my alert]
14767 [main] DEBUG javapns.notification.Payload  - Adding sound [default]
14767 [main] DEBUG javapns.notification.Payload  - Adding custom Dictionary [eid] = [193790]
14776 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.notification.PushNotificationManager  - Building Raw message from deviceToken and payload
14776 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.notification.PushNotificationManager  - Built raw message ID 16777217 of total length 135
14777 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.notification.PushNotificationManager  - Attempting to send notification: {"aps":{"sound":"default","alert":"blah, blah my alert"},"eid":"193790"}
14777 [JavaPNS grouped notification thread in QUEUE mode] DEBUG javapns.notification.PushNotificationManager  -   to device: [my device number]

就是这样,没有冲洗...

4

1 回答 1

0

您是否在服务器或其他防火墙设备上配置了 iptables?

  • 也许需要允许端口 2195。

尝试使用 telnet 进行测试:

$ telnet gateway.sandbox.push.apple.com 2195

你启用了 SELinux 吗?检查以下设置:

$ getebool -a | grep httpd

httpd_can_network_connect --> ?

确保它已打开。

您是否查看了 javapns repo 站点上的文档?

让我们知道怎么回事。

账单

于 2012-04-09T02:59:00.547 回答