mcxiaoke / android-volley

DEPRECATED
4.29k stars 1.56k forks source link

Throws timeout error before predefined timeout milliseconds occurs #112

Open mamatagelanee07 opened 9 years ago

mamatagelanee07 commented 9 years ago

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.

fairytale2016 commented 9 years ago
/** 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));

mamatagelanee07 commented 9 years ago

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.

fairytale2016 commented 9 years ago

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 你能解决你的疑问(实在不会了 :))

mamatagelanee07 commented 9 years ago

Hi fairytale2016,

Issue not solved but thanks for your help.

fairytale2016 commented 9 years ago

no 3Q :)