Skip to content

Use HttpRequestRetry ktor plugin #233

@LotuxPunk

Description

@LotuxPunk

By default, the Ktor client doesn't retry requests that failed due to network or server errors. You can use the HttpRequestRetry plugin to configure the retry policy for failed requests in various ways: specify the number of retries, configure conditions for retrying a request, or modify a request before retrying.

https://ktor.io/docs/client-request-retry.html

Default configuration should be good enough:

val client = HttpClient(CIO) {
    install(HttpRequestRetry) {
        retryOnServerErrors(maxRetries = 3)
        exponentialDelay()
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions