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

Alexander Minyaev

07/16/2020, 9:31 AM
Hello! How to retry request in
HttpClientFeature
after
Exception
? Now, I have next code:
Copy code
override fun install(feature: ExceptionFeature, scope: HttpClient) {
            scope.sendPipeline.intercept(HttpSendPipeline.Before) {
                for (counter in 0..2) {
                    try {
                        proceed()
                        break
                    } catch (e: IOException) {
                        println("IO Error :$counter")
                        if (counter == 2) {
                            throw e
                        }
                    }
                }
            }
e

e5l

07/16/2020, 9:32 AM
Hey, you can use
HttpSend
feature for that. It allows you to repeat the request(as in HttpRedirect feature)
1
a

Alexander Minyaev

07/16/2020, 10:23 AM
@e5l I'm sorry for my mistake, maybe you don't understand my problem. I need retry request after exception (example micro problems with connection). If I will haven't connection program throw exception in here and it don't gone to interceptors. I could be wrong.
7 Views