0

これは私が呼び出す関数です:

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

URL を試してみました: 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)

これを修正するにはどうすればよいですか? わかりません。detaulf 再試行ポリシーを変更しようとしましたが、何も役に立ちません

4

1 に答える 1

0

Volley の代わりに HTTPClient を使用して実行したところ、うまくいきました。

 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);
于 2016-11-18T14:43:02.507 に答える