Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does RetryPolicy work? #133

Open
nologinatgit opened this issue Oct 24, 2015 · 1 comment
Open

How does RetryPolicy work? #133

nologinatgit opened this issue Oct 24, 2015 · 1 comment

Comments

@nologinatgit
Copy link

I have the following interface:

  @GET("/information")
  @RetryPolicy(timeout = 10000)
  void GetInformation(Callback< List< Information>> callback);

This is my setup:

myService = new Wasp.Builder(MainActivity.this)
        .setEndpoint(BASE_API_URL)
        .build()
        .create(IMyService.class);

I call it like this:

 myService .GetInformation(new Callback< List< Information>>()
        {
          @Override
          public void onSuccess(Response response, List< Information> informations)
          {
            Log.w("DEBUG", "Success");            
          }

          @Override
          public void onError(WaspError error)
          {
            Log.w("DEBUG", error);
          }
        });`

Sometimes I get this back:

 Wasp Error:  Status Code: 0 Url http://mysite.com/api/information
     at com.orhanobut.wasp.VolleyNetworkStack$VolleyListener.onErrorResponse(VolleyNetworkStack.java:171)
     at com.android.volley.Request.deliverError(Request.java:590)
     at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:101)
     at android.os.Handler.handleCallback(Handler.java:615)
     at android.os.Handler.dispatchMessage(Handler.java:92)
     at android.os.Looper.loop(Looper.java:137)
     at android.app.ActivityThread.main(ActivityThread.java:4802)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:511)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:813)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:580)
     at dalvik.system.NativeStart.main(Native Method)

What does code 0 mean? If I set the retry policy, shouldn't it retry a few times? How should I set it? The Wiki is very thin.

@orhanobut
Copy link
Owner

Error information indeed doesn't contain enough information about what happened. We have an open issue for improving. You also need to add other values, currently you only set timeout.

@RetryPolicy(timeout = 10000, maxNumRetries=3, backoffMultiplier=0.75)

On the other hand, default values are set if they are null. In your case it should retry 3 times but I also don't know the reason, usually status code=0 is returned when there is no connection established.

I'll try to spare some time to improve wasperror in order to provide much better information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants