Skip to content

Commit

Permalink
retry på flere feil
Browse files Browse the repository at this point in the history
  • Loading branch information
b162214 committed Oct 13, 2023
1 parent 1e8d256 commit fceb4d3
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import io.ktor.client.plugins.HttpRequestRetry
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.serialization.kotlinx.json.json
import no.nav.helsearbeidsgiver.utils.json.jsonConfig
import io.ktor.client.network.sockets.SocketTimeoutException
import io.ktor.client.network.sockets.ConnectTimeoutException
import io.ktor.client.plugins.HttpRequestTimeoutException

internal fun createHttpClient(): HttpClient =
HttpClient(Apache5) { configure() }
Expand All @@ -22,6 +25,9 @@ internal fun HttpClientConfig<*>.configure() {
maxRetries = 3
retryOnServerErrors(maxRetries)
retryOnExceptionIf { _, cause ->
cause is SocketTimeoutException ||
cause is ConnectTimeoutException ||
cause is HttpRequestTimeoutException ||
cause is java.net.SocketTimeoutException
}
exponentialDelay()
Expand Down

0 comments on commit fceb4d3

Please sign in to comment.