JavaPNS - 从笔记本电脑正常工作,而不是从服务器?
问题描述:
我一直在这上面冲击我一阵子,希望有人能帮忙吗? 我有一些JavaPNS代码,当从我的本地机器运行时,它会将罚款推到我的设备,但是,当我将该代码复制到我的服务器时,一切运行正常,没有错误,但我从来没有得到我的设备上的警报? 从我的服务器检查日志与我的本地框相比,我发现我从来没有在我的服务器上得到刷新消息,我使用30个线程的JavaPNS队列。在这两种情况下,本地盒子和服务器,我发送少于30个警报。JavaPNS - 从笔记本电脑正常工作,而不是从服务器?
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);
}
}
----下面是齐平的消息从我的地方框--------------
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]
就是这样,没有冲水......
答
你有服务器或其他一些防火墙设备上配置了iptables的?
- 也许端口2195需要被允许。
使用telnet测试尝试:
$远程登录gateway.sandbox.push.apple.com 2195
您是否启用SELinux的?检查以下设置:
$ getsebool -a | grep httpd
httpd_can_network_connect - >?
确认它已打开。
您是否检查了javapns回购网站上的文档?
让我们知道它是如何发展的。
Bill
谢谢比尔。我不认为这是问题,因为我可以使用这种方法从服务器发送警报:Push.payloads(密钥仓库,密码,生产,列表); 我决定切换到批量发送而不是队列发送这种方法... – steve 2012-04-10 02:26:35