以下是我的问题情节。
任何想法我怎么能摆脱我收到的'-1'回应。在哪种情况下服务器返回此代码?
我在下面发布我的示例代码。
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();
提前致谢
答案 0 :(得分:0)
HttpsURLConnection failing intermittently to the same URL
看看是否是同一个问题,如果那个修复程序可以帮助你解决问题。 祝你好运!