Note that there are some explanatory texts on larger screens.

plurals
  1. PO'-1' error during HTTPS communication
    text
    copied!<p>Below is my problem scenario.</p> <ul> <li>My Server is on running on https.</li> <li>Doing connection with ‘HttpURLConnection’ api &amp; already tried ‘HttpClient’ as well earlier but both are showing same issue.</li> <li>Server certificate is ‘Verisign Class 3’ certificate.</li> <li>Every alternate request sent to server, receives ‘-1’ in http response code. For e.g. If my first request is successful (200 code) second request would get (-1) code, then again successful &amp; then again 4th request gets -1 in response. I’m not sure why this -1 code is returned &amp; there’s not description on HTTP standard site as well.</li> </ul> <p>Any idea how can i get rid off this '-1' response i receive. In which scenario server returns this code? </p> <p>I'm posting my sample code below.</p> <hr> <pre><code>HttpURLConnection connection; SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, new TrustManager[] { new TrustManager() }, new SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(new MyHostnameVerifier()); connection = (HttpsURLConnection) httpUrl.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Length", String.valueOf(requestBinary.length)); connection.setRequestProperty("Content-Type","octet/x-application-csam"); connection.setDoInput(true); connection.setDoOutput(true); connection.setConnectTimeout(30000); connection.connect(); connection.getOutputStream().write(requestBinary); int responseCode = connection.getResponseCode(); </code></pre> <hr> <p>Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload