'Ktor Android Retry Policy
How can I configure a custom retry policy for an Android Ktor Client?
My client instantiation code:
private var client: HttpClient = HttpClient(Android) {
install(JsonFeature) {
serializer = KotlinxSerializer()
}
}
Thanks in advance!
Solution 1:[1]
Based on Aleksei's comment, here is a solution:
private var client: HttpClient = HttpClient(Android) {
install(ContentNegotiation) {
json()
}
//ktor.io/docs/eap/client-retry.html for more options
install(HttpRequestRetry) {
maxRetries = 25
constantDelay(2000, 1000)
}
}
Important: work's only for Ktor 2.0.0 or above.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Geraldo Neto |
