首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JavaPNS --在笔记本电脑上工作得很好,而不是服务器?

JavaPNS --在笔记本电脑上工作得很好,而不是服务器?
EN

Stack Overflow用户
提问于 2012-04-06 15:51:46
回答 1查看 1.5K关注 0票数 0

我已经对这件事大发雷霆了,希望有人能帮忙?我有一些JavaPNS代码,当从本地机器运行时,这些代码可以很好地推送到我的设备上,但是,当我将代码复制到服务器上时,一切正常运行,没有错误,但是我的设备上从来没有收到警报?与本地框相比,在检查了服务器上的日志之后,我注意到我从未在服务器上获得过刷新消息,我使用的是带有30个线程的JavaPNS队列。在这两种情况下,本地框和服务器,我发送的警报少于30个。

代码语言:javascript
复制
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);
}
}

--下面是我本地盒子里的冲洗信息

代码语言:javascript
复制
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

我能用某种方式从队列中强行冲出吗?

下面是服务器JavaPNS日志记录

代码语言:javascript
复制
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]

仅此而已,没有冲洗..。

EN

回答 1

Stack Overflow用户

发布于 2012-04-09 02:59:00

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

  • 可能需要允许端口2195。

尝试使用telnet测试:

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

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

$ getsebool -a \ grep httpd

httpd_can_network_connect ->?

一定要开着。

您检查了javapns回购站点上的文档吗?

让我们知道是怎么回事。

帐单

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10045879

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档