Android Retrofit 2: Programmatically increase timeout by 10 seconds

Viewed 153

There is a situation where if my API call fails due timeout, I have to retry by increasing the timeout by 20 seconds. All the examples of retrofit I searched show static timeout. Something like in following How to set timeout in Retrofit library?

or ask to put timeout in @Headers field. But this is not suitable in my case. onFailure(), I want to

  1. increase the timeout by 20 seconds for retry attempt and then
  2. reset to original timeout.
0 Answers
Related