Android Volley Double Post When Have Slow Request

Android Volley double post when have slow request

Add the following values to your Request object:

request.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

Here:
request is your object of JsonObjectRequest. Change the value of multiplicator according to the DEFAULT TIMEOUT VALUE in DefaultRetryPolicy class in Volley.

You can also set the first argument to 0, like below:

request.setRetryPolicy(new DefaultRetryPolicy(
0,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

Timeout for server request made using Volley only on Android not iOS

As i have tried to get solution of this issue for about two months, I did not get any perfect solution. Though I analyze some facts as below :

  1. You can upgrade your server's performance
  2. I have tried making web-service request using HttpURLConnection but still getting same issue over there.

So I think this issue is not specific from volley, but you getting this issue then i would suggest to increase server performance with customizing below RetryPolicy:

int x=2;// retry count
request.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 48,
x, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

Hope it will help.

Suggestions are always welcome :)

Please comment below if you found more proper solution.

Thanks.!



Related Topics



Leave a reply



Submit