Я подозреваю, что у вас установлены дополнительные тайм-ауты платформы, например, тайм-аут моего теста после 1: 15.
package okhttp3.curl
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import okhttp3.logging.LoggingEventListener
import java.util.concurrent.TimeUnit
fun main() {
val listener = LoggingEventListener.Factory()
val client = OkHttpClient.Builder()
.eventListenerFactory(listener)
.callTimeout(2, TimeUnit.MINUTES)
.connectTimeout(2, TimeUnit.MINUTES)
.writeTimeout(2, TimeUnit.MINUTES)
.readTimeout(2, TimeUnit.MINUTES)
.build()
val response: Response = client.newCall(
Request.Builder().url("http://203.0.113.1").build()).execute()
println(response.request.url)
}
Вывод
Mar 29, 2020 12:33:58 PM okhttp3.internal.platform.Platform log
INFO: [72 ms] connectStart: /203.0.113.1:80 DIRECT
Mar 29, 2020 12:35:14 PM okhttp3.internal.platform.Platform log
INFO: [75599 ms] connectFailed: null java.net.ConnectException: Failed to connect to /203.0.113.1:80
Mar 29, 2020 12:35:14 PM okhttp3.internal.platform.Platform log
INFO: [75601 ms] callFailed: java.net.ConnectException: Failed to connect to /203.0.113.1:80
Exception in thread "main" java.net.ConnectException: Failed to connect to /203.0.113.1:80