I installed the Timeout feature of the Ktor HttpClient, because I have some specific request that might take a long time, so I installed the feature:
httpClient = HttpClient(CIO) {
install(HttpTimeout) {
requestTimeoutMillis = 60000
}
engine {
maxConnectionsCount = 10000
endpoint.apply {
maxConnectionsPerRoute = 1000
pipelineMaxSize = 100
keepAliveTime = 5000
connectTimeout = 5000
connectRetryAttempts = 3
}
}
}
and in my request, I specifically overwrite the requestTimeout:
<http://httpClient.post|httpClient.post><MyResponse> {
url(myUrl)
contentType(ContentType.Application.Json)
timeout {
requestTimeoutMillis = TimeUnit.MINUTES.toMillis(30)
}
body = myBody
}
But I still got a coroutine
TimeoutCancellationException
after 15 seconds. I then specified the engine.endpoint.requestTimeout to be longer and the Exception went away - so am I not able to overwrite the CIO engines timeout with the Timeout feature? By the Timeout feature documentation, a
HttpRequestTimeoutException
should be thrown, not a Coroutine timeout exception, so it appears to get ignored. Can I overwrite the request timeout for CIO for a specific request? Or should I increase the CIO timeout a lot and then use the HttpTimeout feature to reduce it again?