I have code for making POST requests using HttpsUrlConnection, the code works fine, but some of my users have SIM cards with a closed user group, and they need to install a proxy server in their apn settings. If they install a proxy server, I need to change the code. I tried this:
HttpsURLConnection connection = null; DataOutputStream outputStream = null; DataInputStream inputStream = null; String urlServer = "https://xxx"; String boundary = "*****"; try { URL url = new URL(urlServer); SocketAddress sa = new InetSocketAddress("[MY PROXY HOST]",[My PROXY PORT]); Proxy mProxy = new Proxy(Proxy.Type.HTTP, sa); connection.setDoInput(true); connection.setDoOutput(true); connection.setUseCaches(false); connection.setRequestMethod("POST"); connection.setRequestProperty("Connection", "Keep-Alive"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;boundary=" + boundary);
now I get the error message:
javax.net.ssl.SSLException: connection closed by peer
If I use url.OpenConnection () wuithout Proxy and without Proxysettings in apn, the code works, what could be the problem?
source share