Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Volley request retry policy doesn't consider timeout

I've set 1500 as initialTimeoutMs in DefaultRetryPolicy as below but it doesn't consider the timeout:

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

I disconnected the WiFi on my device to test it's timeout and I saw these times in the Logcat:

2019-12-16 14:28:15.892 I/MyClass: request sent
2019-12-16 14:28:35.930 I/MyClass: request caught onError

It took more than 20 seconds while I expected to catch either onResponse or onError after 1.5 seconds!!!

like image 310
Alireza Noorali Avatar asked Dec 16 '19 11:12

Alireza Noorali


Video Answer


1 Answers

According to your configure. Your timeout should be 3 secs. Referring to http://prasadthangavel.blogspot.com/2013/12/why-volley-android-has-provided-two.html

I think you should make DEFAULT_BACKOFF_MULT zero.

like image 96
littlebear333 Avatar answered Sep 20 '22 13:09

littlebear333