0

I have unexpected end of stream on Connection error when using volley. I was searching, but I couldn't find a solution:

  if (ConnectedToInternet.is(getActivity())) {
        String tag_string_req = "news";
        String url = ExtraMthd.BASE_API + "news.php?news&from=" + (refresh ? 0 : newss.size()) + "&isadmin=" + (Admin ? 1 : 0);
        progressBar.setVisibility(View.VISIBLE);
        JsonArrayRequest req = new JsonArrayRequest(url,
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        Log.d("news fragment", response.toString());

                        progressBar.setVisibility(View.INVISIBLE);
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.d("news fragment", "Error: " + error.getMessage());
                ExtraMthd.toast(getActivity(), "خطایی رخ داد؛\n" + error.getMessage());
                progressBar.setVisibility(View.INVISIBLE);
            }
        });
        App.getInstance().addToRequestQueue(req, tag_string_req);

    }

error:

D/news fragment: Error: java.io.IOException: unexpected end of stream on Connection{ardakantennis.ir:80, proxy=DIRECT@ hostAddress=158.58.185.39 cipherSuite=none protocol=http/1.1} (recycle count=0)
petrumo
  • 1,116
  • 9
  • 18
abbasalim
  • 3,118
  • 2
  • 23
  • 45
  • My guess is that the server is disconnecting on its end or responding with something invalid for a full HTTP response. Does the request complete successfully with the entire stream if you call it via another tool, like Postman or a desktop web browser? Does that response body parse as valid JSON? – Jon Adams Jan 03 '17 at 15:12
  • 2
    http://stackoverflow.com/questions/8202813/unexpected-end-of-stream-error-on-download – sivaBE35 Jan 03 '17 at 15:13
  • @siva35 i have problem with volley – abbasalim Jan 04 '17 at 11:00

0 Answers0