我在DefaultRetryPolicy中将1500设置为initialTimeoutMs,如下所示,但它不考虑超时:
request.setRetryPolicy(new DefaultRetryPolicy(1500
, DefaultRetryPolicy.DEFAULT_MAX_RETRIES
, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
我断开了设备上的WiFi的连接以测试其超时,并且在Logcat中看到了这些时间:
2019-12-16 14:28:15.892 I/MyClass: request sent
2019-12-16 14:28:35.930 I/MyClass: request caught onError
[我花了超过20秒的时间,但我希望在1.5秒后捕获onResponse或onError !!!
使用5秒钟,因为15秒钟用于超时,因此要花费更多时间。