Hi. Trying to set timeout on KMM, For test purpose...
# ktor
a
Hi. Trying to set timeout on KMM, For test purposes set a pretty small value and expect to receive a timeout exception. On Android I am capable to receive an error, but on iOS my request execute as usual. What am I missing?
Copy code
internal fun defaultHttpClient(): HttpClient = HttpClient {
    install(HttpTimeout) {
        connectTimeoutMillis = 10
        requestTimeoutMillis = 10
    }
}
ktor 1.6.4
a
Seems like only the
socketTimeoutMillis
timeout works for the
ios
engine.
a
As far as I understand there are no support for WS on ktor 1.6.4
a
For iOS no. Only since the 2.0.0 version.
a
So, is
socketTimeoutMillis
related to the iOS REST or WS?
BTW, WS was released 2 days ago, no?
a
So, is
socketTimeoutMillis
related to the iOS REST or WS?
It’s related to both.
BTW, WS was released 2 days ago, no?
The version 2.0.0 of Ktor was released a few days ago.
🎉 1
a
Thanks. Now, I got it.
@Aleksei Tirman [JB] Still trying to understand what would be the best approach to set timeout values that will work same way for both Android and iOS. As you mentioned before, ios engine respects only
socketTimeout
. Would it be correct to share this value for both platforms? I played around with numbers and seems like Android respects the
requestTimeoutMillis
more than
socketTimeout
. For instance setting
Copy code
install(HttpTimeout) {
        socketTimeoutMillis = 10
        requestTimeoutMillis = 100
    }
will fail with: io.ktor.client.features.HttpRequestTimeoutException: Request timeout has expired [url=http://myurl, request_timeout=100 ms] even that socketTimeoutMillis has lower value. Thats a little bit confusing, why...