1
我看到此問題之前詢問過(Volley.NoConnectionError : java.io.EOFException 0)但未回答。EOFException排球錯誤
我有完全相同的問題。它工作的很好,只是某個時候......主要是當我第一次運行它時發生EOFException。
這裏是我的排球請求(忽略壞格式化):
public void makeJsonObjectRequest() {
Log.e("TMS", "makeJsonObjectRequest 111 ");
final CountDownLatch cdl = new CountDownLatch(1);
JsonArrayRequest req = new JsonArrayRequest(urlJsonArry,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d("TMS", "aaaaaa " + response.toString());
try {
jsonResponse = "";
String id = null;
String naslov = null;
String akter = null;
String akter_id = null;
String slika = null;
String izjava = null;
String izvor = null;
String datum_izjave = null;
String tip_ocena = null;
String kategorija = null;
String status = null;
String komentar_istinomera = null;
String tagovi = null;
for (int i = 0; i < response.length(); i++) {
NewsItem newsItem = new NewsItem();
JSONObject person = (JSONObject) response.get(i);
// Parsing json object response response will be a json object
id = person.getString("id");
naslov = person.getString("naslov");
akter = person.getString("akter");
akter_id = person.getString("akter_id");
slika = person.getString("slika");
izjava = person.getString("izjava");
izvor = person.getString("izvor");
datum_izjave = person.getString("datum_izjave");
tip_ocena = person.getString("tip_ocena");
kategorija = person.getString("kategorija");
status = person.getString("status");
komentar_istinomera = person.getString("komentar_istinomera");
tagovi = person.getString("tagovi");
jsonResponse += "id: " + id + "\n\n";
jsonResponse += "naslov: " + naslov + "\n\n";
jsonResponse += "akter: " + akter + "\n\n";
jsonResponse += "akter_id: " + akter_id + "\n\n";
jsonResponse += "slika: " + slika + "\n\n";
jsonResponse += "izjava: " + izjava + "\n\n";
jsonResponse += "izvor: " + izvor + "\n\n";
jsonResponse += "datum_izjave: " + datum_izjave + "\n\n";
jsonResponse += "tip_ocena: " + tip_ocena + "\n\n";
jsonResponse += "kategorija: " + kategorija + "\n\n";
jsonResponse += "status: " + status + "\n\n";
jsonResponse += "komentar: " + komentar_istinomera + "\n\n";
jsonResponse += "tagovi: " + tagovi + "\n\n";
/* Log.e(TAG,"JSON IS: " + id);
Log.e(TAG,"JSON IS: " + naslov);
Log.e(TAG,"JSON IS: " + akter);
Log.e(TAG,"JSON IS: " + akter_id);
Log.e(TAG,"JSON IS: " + slika);
Log.e(TAG,"JSON IS: " + izjava);
Log.e(TAG,"JSON IS: " + izvor);
Log.e(TAG,"JSON IS: " + datum_izjave);
Log.e(TAG,"JSON IS: " + tip_ocena);
Log.e(TAG,"JSON IS: " + kategorija);
Log.e(TAG,"JSON IS: " + status);
Log.e(TAG, "JSON IS: " + komentar);
Log.e(TAG, "JSON IS: " + tagovi);*/
newsItem.setIds(id);
newsItem.setNaslov(naslov);
newsItem.setAkter(akter);
newsItem.setAkterId(akter_id);
newsItem.setSlika(slika);
newsItem.setIzjava(izjava);
newsItem.setIzvor(izvor);
newsItem.setDatum_izjave(datum_izjave);
newsItem.setTip_ocena(tip_ocena);
newsItem.setKategorija(kategorija);
newsItem.setStatus(status);
newsItem.setKomentar_istinomera(komentar);
newsItem.setTagovi(tagovi);
newsItemList.add(newsItem);
//int size = newsItemList.size();
//Log.d("TMS", "getNaslov: " + newsItem.getNaslov() + " SIZE: " + size);
cdl.countDown();
}
} catch (JSONException e) {
e.printStackTrace();
Log.e("TMS", "makeJsonObjectRequest 3333 JSONException");
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
Log.e("TMS", "makeJsonObjectRequest 44444 onErrorResponse" + error.getMessage());
}
});
req.setRetryPolicy(new DefaultRetryPolicy(5000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
// Adding request to request queue
volleyRequest.getInstance().addToRequestQueue(req);
try {
cdl.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
錯誤監聽器打印該行:
Log.e("TMS", "makeJsonObjectRequest 44444 onErrorResponse" + error.getMessage());
makeJsonObjectRequest 44444 onErrorResponse java.io.EOFException的
和凌空錯誤日誌:
E/Volley:[154] BasicNetwork.performRequest:http://www的意外響應代碼200。