https://kotlinlang.org logo
#ktor
Title
# ktor
g

Goku

03/15/2021, 7:27 AM
Is there a way to retry requests with Ktor ? I’ve tried using HttpSend feature, but wasn’t able to get the request to retry 😞 I am referring to client implementation ofc
1
Found a way, nevermind. I have set timeout to be very low and it didn’t even manage to retry the request 😄 If anyone needs it, a very basic sample:
Copy code
this.install(HttpSend) {
    intercept { httpClientCall, httpRequestBuilder ->
        println(message = "Request URL: ${httpClientCall.request.url}")

        // Some retry strategy logic...
        // TODO: ...

        if (shouldRetry) {
            execute(httpRequestBuilder)
        } else {
            httpClientCall
        }
    }

    maxSendCount = 10
}
@sushma nayak
10 Views