我正在尝试使用JavaPNS 2.2通过代理推送到苹果设备。我的java应用程序运行在防火墙后面的jBoss上,与苹果服务器通信的唯一方式就是通过那个代理。
public ApplePushNotification(File certificate){
super();
ProxyManager.setProxy("myproxy", "myport");
this.certificate = certificate;
}我得到了这个异常。
javapns.communication.exceptions.CommunicationException: Communication exception: java.io.IOException: Unable to tunnel through. Proxy returns "HTTP/1.1 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )"因此,我读取了ProxyManager.java文件以找到授权的方法。我发现了这个:
/**
* Configure the authorization for the proxy configured through the setProxy method.
*
* @param username the user name to use
* @param password the password to use
*/
public static void setProxyBasicAuthorization(String username, String password) {
setProxyAuthorization(encodeProxyAuthorization(username, password));
}我试图使用像ProxyManager.setProxy("myproxy", "myport");这样的静态方法,但是我不能使用它。我真的很感谢你的帮助。谢谢
其他链接:
http://code.google.com/p/javapns/source/browse/trunk/src/javapns/communication/ProxyManager.java
http://code.google.com/p/javapns/
发布于 2012-11-27 15:37:15
最后,我让它在JavaPNS 2.3Beta中工作。
ProxyManager.setProxy("myProxy", "myPort");
ProxyManager.setProxyBasicAuthorization("username", "password");如果你想让它在JavaPNS 2.2上运行,你需要自己实现它。但是使用2.3是一种更简单的方法。只需将javaPNS_2.3_Beta_2.jar作为库包含到项目中即可。
https://github.com/azinman/javapns/blob/master/JavaPNS_2.3_Beta_2.jar?raw=true
https://stackoverflow.com/questions/13562942
复制相似问题