Sathish
Sathish

Reputation: 519

What is the default retry policy mechanism OKHttp? (Android)

I have been trying to find an answer for this one and could not find any.

There are many techniques where we can implement retry in OkHttp with retrofit and also configure it

As per the document https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/-builder/retry-on-connection-failure/ fun retryOnConnectionFailure(retryOnConnectionFailure:Boolean): Builder

We can configure whether retry is required or not. And the default value is true.

But what is the default retry mechanism in OkHttp

How many times will the call be made?

What is the default exponential logic in OkHttp?

Can anyone help in this

Upvotes: 7

Views: 11100

Answers (1)

Yuri Schimke
Yuri Schimke

Reputation: 13448

OkHttp will try to retry a request when the following is generally true

There is no advanced logic in OkHttp for this, if you need particular retry logic you can consider disabling any automatic retries and implementing exactly the strategy you need.

See also https://medium.com/inloopx/okhttp-is-quietly-retrying-requests-is-your-api-ready-19489ef35ace

Upvotes: 8

Related Questions