androidnetwork-programminggetandroid-volleyprotocolexception

Volley gives a Protocol Exception error, 21 too many followups


This is the function I call:

 public static void sendData(final Integer type , final String url, final Context context, final CrudStateCallback back){
    StringRequest jr = new StringRequest(type, url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    System.out.println(response.substring(0,100));
                    Log.i("","WSCALLS response is: " + response);
                    if(back != null)
                        back.onResponse(200, response);
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.i("","WSCALLS Something went wrong!");
            error.printStackTrace();
            String errorS = "error is null";
            int code = 0;
            try {
                if (error != null) {
                    errorS = error.getMessage();
                    code = error.networkResponse.statusCode;
                }
            }catch (Exception e){
                Log.e("","WSCALLS error is in send data:" + e.getMessage());
            }
            if(back != null)
                back.onResponse(code, errorS);
        }
    });
    if (Utils.networkIsAvailable( context)) {
        jr.setRetryPolicy(new DefaultRetryPolicy(60 * 1000, 0, 1));
        VidyoSampleApplication.mRequestQueue.add(jr);
    }
}

With the following params:

WSCalls.sendData(Request.Method.GET, "https://control.facetalk.nl/vidyologs/call_start.php?meetingID=82000005715&profielID=51108581", VidyoSampleActivity.this, null);

I tried the url: https://control.facetalk.nl/vidyologs/call_start.php?meetingID=82000005715&profielID=51108581 and it works, I get a "200" on postman. But Volley will return the following error:

11-17 16:54:57.094: W/System.err(3415): com.android.volley.NoConnectionError: java.net.ProtocolException: Too many follow-up requests: 21
11-17 16:54:57.094: W/System.err(3415):     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:151)
11-17 16:54:57.094: W/System.err(3415):     at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
11-17 16:54:57.094: W/System.err(3415):     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:401)
11-17 16:54:57.094: W/System.err(3415):     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:501)
11-17 16:54:57.094: W/System.err(3415):     at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
11-17 16:54:57.094: W/System.err(3415):     at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)
11-17 16:54:57.095: W/System.err(3415):     at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:110)
11-17 16:54:57.095: W/System.err(3415):     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:96)

What can I do to fix this? I don't understand, I tried modifying the detaulf retry policy but nothing helps


Solution

  • I did it using HTTPClient instead of Volley and it worked:

     HttpClient httpClient = new DefaultHttpClient();
                    httpClient.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
                    HttpPost httpPost = new HttpPost(url);
                    HttpResponse response = httpClient.execute(httpPost);
                    String responseBody = "";
                    BufferedReader buffer = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                    String s = "";
                    while ((s = buffer.readLine()) != null)
                        responseBody += s;
                    Log.i("","WSCAlls response body is:" + responseBody);