我已經搜索了很多這種異常,這種情況發生了,但我沒有找到任何相關的答案,可以解決我的問題, 我使用HttpURLConnection
得到響應從URL的XML,它工作正常,但有時我得到這個異常:
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
, 我用下面的代碼,併爲url1是我的網址這給XML。java.net.SocketException:recvfrom失敗:ECONNRESET(連接重置由對等)發生了一些
url=new URL(url1);
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoInput(true);
urlConnection.connect();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String result, line = reader.readLine();
result = line;
while((line=reader.readLine())!=null)
{
result+=line;
}
System.out.println("Result: "+result);
有一個連接超時http://stackoverflow.com/questions/11638634/android-how-to-set-a-http-connection-timeout-and-反應它 – Raghunandan 2013-05-11 04:31:38
我有同樣的問題.. – Dediqated 2013-05-22 10:24:43
可能重複[獲取「SocketException:連接重置由對等」在Android](http://stackoverflow.com/questions/11207394/getting-socketexception-connection-reset在Android平臺上) – 2014-04-09 02:09:09