I see this `
How to set connection timeout with OkHttp
But this link for Java(Android) Language.I want to use kotlin Language... ` I am using OkHttp library
val client = OkHttpClient()
val time = client.connectTimeoutMillis() // it's get only methood but i looking for method for set Timeout
and my trouble is I cannot find how to set connection timeout and socket timeout For Kotlin.
A Builder
is required, there are no setters available. With OkHttp 3.9.1 you can do this:
val client = OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With