wasp
wasp copied to clipboard
Volley appears to ignore timeout settings.
My service interface looks like this:
public interface IMyService {
@GET("/myOperation")
Entitiy[] myOperation();
}
I build the service like this:
new Wasp.Builder(context)
.setEndpoint(MY_ENDPOINT)
.setParser(new MyGsonParser())
.setRequestInterceptor(new MyRequestInterceptor(context))
.build()
.create(IMyService.class);
Parser is simple and irrelevant, interceptor looks like this:
private final static class MyRequestInterceptor implements RequestInterceptor {
public MyRequestInterceptor (Context context) {
....
}
@Override
public void onHeadersAdded(Map<String, String> headers) {
}
@Override
public void onQueryParamsAdded(Map<String, Object> params) {
}
@Override
public WaspRetryPolicy getRetryPolicy() {
return new WaspRetryPolicy(REQUEST_TIMEOUT/*90 seconds*/, MAX_REQUEST_RETRY, 1);
}
@Override
public AuthToken getAuthToken() {
return new AuthToken(....);
}
}
When I call myOperation
from `IMyService' I get a timeout exception after approximately two seconds:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.reflect.UndeclaredThrowableException
at $Proxy9.myOperation(Unknown Source)
at mypackage.controllers.AccountController.login(AccountController.java:51)
at mypackage.activities.LoginActivity$LoginAction.doInBackground(LoginActivity.java:63)
at mypackage.activities.LoginActivity$LoginAction.doInBackground(LoginActivity.java:48)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.util.concurrent.ExecutionException: com.android.volley.TimeoutError
at com.android.volley.toolbox.RequestFuture.doGet(RequestFuture.java:117)
at com.android.volley.toolbox.RequestFuture.get(RequestFuture.java:97)
at com.orhanobut.wasp.VolleyNetworkStack.addToQueueSync(VolleyNetworkStack.java:70)
at com.orhanobut.wasp.VolleyNetworkStack.invokeRequest(VolleyNetworkStack.java:124)
at com.orhanobut.wasp.NetworkHandler.invokeSyncRequest(NetworkHandler.java:114)
at com.orhanobut.wasp.NetworkHandler.invoke(NetworkHandler.java:96)
at java.lang.reflect.Proxy.invoke(Proxy.java:397)
at $Proxy9.myOperation(Unknown Source)
at mypackage.controllers.AccountController.login(AccountController.java:51)
at mypackage.activities.LoginActivity$LoginAction.doInBackground(LoginActivity.java:63)
at mypackage.activities.LoginActivity$LoginAction.doInBackground(LoginActivity.java:48)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.android.volley.TimeoutError
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:147)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:114)
The same exception happens if I add
@RetryPolicy(timeout = 90000, backoffMultiplier = 1, maxNumRetries = 1)
annotation to the operation.
When debugging through your code I saw my timeout value being read and used in VolleyNetworkStack.java#L70, but I have no idea why volley throws a timeout exception almost immediately. If my remote operation takes less than a couple of seconds to execute then everything works just fine.
I am also being affected by this problem. Any update on this?