JavaPNS via Apache Web Proxy

493 Views Asked by At

My push java app is behind a web proxy. I used below code to set proxy:

ProxyManager.setProxy("", "");

After executed, I got:

javapns.communication.exceptions.CommunicationException: Communication exception: java.io.IOException: Unable to tunnel through. Proxy returns "HTTP/1.1 403 Proxy Error"

Please guide me how to solve this issue.

1

There are 1 best solutions below

0
On

If there is a username and password required for the proxy, then you also need to set the proxyAuthorization of the ProxyManager. To encode the username and password, you can use the existing encodeProxyAuthorization method of the ProxyManager:

String encodeProxyAuthorization = ProxyManager.encodeProxyAuthorization(username, password);
ProxyManager.setProxyAuthorization(encodeProxyAuthorization);