以下是我用于验证IAP交易收据的代码。 httpsURLConnection.getOutputStream()抛出SocketException:连接重置。 那是什么遗失?
公共类HttpsClient {
public static void main(String[] args) {
HttpURLConnection.setFollowRedirects(false);
JSONObject jsonObject = new JSONObject();
jsonObject
.put("receipt-data",
"encodeReceipt");
HttpURLConnection con = null;
try {
String url = "https://buy.itunes.apple.com/verifyReceipt";
con = (HttpURLConnection) new URL(url).openConnection();
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) con;
httpsURLConnection.setDoOutput(true);
OutputStreamWriter wr = null;
wr = new OutputStreamWriter(httpsURLConnection.getOutputStream());
wr.write(jsonObject.toString());
wr.flush();
// Get the response
httpsURLConnection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(
httpsURLConnection.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
System.out.print(line);
}
rd.close();
System.out.println(httpsURLConnection);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
答案 0 :(得分:-1)
企业防火墙问题。把它整理出来!