URL queryUrl = new URL(url);
InputStream inputStream = null;
HttpsURLConnection connection = (HttpsURLConnection) queryUrl.openConnection();
connection.setRequestProperty("User-Agent", "My Client");
connection.setRequestMethod("GET");
connection.setDoInput(true);
inputStream = connection.getInputStream();
嗨, 我正在使用上面的代碼來執行HttpGet查詢。 我幾次嘗試一次,發現服務器返回的錯誤代碼爲502或504(這兩種情況都會發生)。 排除異常:當試圖獲得InputStream時獲取錯誤502/504
inputStream = connection.getInputStream()
任何想法?
您的幫助,將不勝感激。 在此先感謝
什麼類型的異常?什麼是服務器日誌說? –
你會發布錯誤StackTrace! –
服務器返回的HTTP響應代碼:504爲URL:....... \t sun.net.www.protocol.http.HttpURLConnection.getInputStream(未知來源)\t sun.net.www.protocol.https.HttpsURLConnectionImpl .getInputStream(Unknown Source)\t Utils.queryGET(BtcE.java:330) –