I have an app that is the default launcher of Android.
When I reboot phone, app runs, then try to make http call and gets this exception:
HTTP FAILED: java.net.SocketTimeoutException: failed to connect to XXXX (port 80) from localAddress.getAddress() (port 42208) after 30000ms
If I leave the app and return to it, http calls starts to work.
This is my client setup:
val client = OkHttpClient.Builder()
client.connectTimeout(30, TimeUnit.SECONDS)
client.readTimeout(30, TimeUnit.SECONDS)
client.writeTimeout(30, TimeUnit.SECONDS )
client.retryOnConnectionFailure(true)
client.connectionPool(ConnectionPool(0, 5, TimeUnit.MINUTES))
client.protocols(listOf(Protocol.HTTP_1_1))
val retrofit = Retrofit.Builder()
.client(client.build())
.addCallAdapterFactory(
RxJava2CallAdapterFactory.create())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(
GsonConverterFactory.create())
.baseUrl(base_url)
.build()
Device: Xiaomi Redmi 8a
OS: MIUI 10.3.3.0 Android 9
Retrofit: 2.7.2
OKHttp: 4.4.0