Volley给出了一个Protocol Exception错误,21次跟进太多了

时间:2016-11-17 15:58:18

标签: android networking get android-volley protocolexception

这是我打电话的功能:

 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);
    }
}

使用以下参数:

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

我尝试了网址:https://control.facetalk.nl/vidyologs/call_start.php?meetingID=82000005715&profielID=51108581并且它有效,我在邮递员身上获得了“200”。 但是Volley将返回以下错误:

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)

我该怎么做才能解决这个问题?我不明白,我尝试修改了detulf重试策略,但没有任何帮助

1 个答案:

答案 0 :(得分:0)

我使用HTTPClient而不是Volley来实现它并且它起作用了:

 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);