android-volley icon indicating copy to clipboard operation
android-volley copied to clipboard

Throws timeout error before predefined timeout milliseconds occurs

Open mamatagelanee07 opened this issue 9 years ago • 5 comments

Hello,

In my application I have set RetryPolicy like below :

request.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 48,
                0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

So here timeout is already set to 120000 milliseocnds means '2 minutes' but in my android application volley throws TimeoutError in deliverResponse method of custom request before timeout (2 minutes) and response contains timeout variable with value of 5234ms.

 @Override
            protected void deliverResponse(String response) {
                super.deliverResponse(response);
            }

So how volley gets timeout before actual timeout?

Please refer this link below for more information about custom request I have created : http://goo.gl/F8d049

Thanks.

mamatagelanee07 avatar Nov 17 '15 07:11 mamatagelanee07

/** The default socket timeout in milliseconds */
public static final int DEFAULT_TIMEOUT_MS = 2500;

/** The default number of retries */
public static final int DEFAULT_MAX_RETRIES = 1;

/** The default backoff multiplier */
public static final float DEFAULT_BACKOFF_MULT = 1f;

try it like this below: request.setRetryPolicy(new DefaultRetryPolicy(60000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

fairytale2016 avatar Nov 19 '15 05:11 fairytale2016

Hello,

Please read below question on stackoverflow carefully : http://goo.gl/F8d049

I have already tried solution you suggested. And again issue is if i set timeout to 120 seconds, then why volley throwing timeout before 120 seconds ?

Thanks for Reply.

mamatagelanee07 avatar Nov 19 '15 05:11 mamatagelanee07

I set retryPolicy before add(request) ,and findits useful for my Android application ,Im really want to help u more but I dont know Volley well,but I find something at a blog in my country that maybe useful for your problem:

Timeout - Specifies Socket Timeout in millis per every retry attempt. Number Of Retries - Number of times retry is attempted. Back Off Multiplier - A multiplier which is used to determine exponential time set to socket for every retry attempt. For ex. If RetryPolicy is created with these values

Timeout - 3000 secs, Num of Attempt - 2, Back Off Multiplier - 2 Attempt 1:

time = time + (time * Back Off Multiplier ); time = 3000 + 6000 = 9000 Socket Timeout = time; Request dispatched with Socket Timeout of 9 Secs Attempt 2:

time = time + (time * Back Off Multiplier ); time = 9000 + 18000 = 27000 Socket Timeout = time; Request dispatched with Socket Timeout of 27 Secs

PS:I am not good at En,Hope 你能解决你的疑问(实在不会了 :))

fairytale2016 avatar Nov 19 '15 06:11 fairytale2016

Hi fairytale2016,

Issue not solved but thanks for your help.

mamatagelanee07 avatar Nov 19 '15 06:11 mamatagelanee07

no 3Q :)

fairytale2016 avatar Nov 19 '15 07:11 fairytale2016