From 2bd4d67c5d70801bf250ab20591714ba480f8301 Mon Sep 17 00:00:00 2001 From: Blatzar <46196380+Blatzar@users.noreply.github.com> Date: Tue, 13 Sep 2022 10:52:51 +0200 Subject: [PATCH] Fixed random timeout crashes --- app/build.gradle | 2 +- .../java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt | 5 +++-- .../com/lagradost/cloudstream3/network/RequestsHelper.kt | 3 --- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ed641a0a..b80c820f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -170,7 +170,7 @@ dependencies { // Networking // implementation "com.squareup.okhttp3:okhttp:4.9.2" // implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.1" - implementation 'com.github.Blatzar:NiceHttp:0.3.2' + implementation 'com.github.Blatzar:NiceHttp:0.3.3' // Util to skip the URI file fuckery 🙏 implementation "com.github.tachiyomiorg:unifile:17bec43" diff --git a/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt b/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt index a64f0d8d..5c3276fa 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt @@ -7,6 +7,7 @@ import com.bumptech.glide.load.HttpException import com.lagradost.cloudstream3.BuildConfig import com.lagradost.cloudstream3.ErrorLoadingException import kotlinx.coroutines.* +import java.io.InterruptedIOException import java.net.SocketTimeoutException import java.net.UnknownHostException import javax.net.ssl.SSLHandshakeException @@ -157,7 +158,7 @@ suspend fun safeApiCall( } safeFail(throwable) } - is SocketTimeoutException -> { + is SocketTimeoutException, is InterruptedIOException -> { Resource.Failure( true, null, @@ -192,7 +193,7 @@ suspend fun safeApiCall( true, null, null, - (throwable.message ?: "SSLHandshakeException") + "\nTry again later." + (throwable.message ?: "SSLHandshakeException") + "\nTry a VPN or DNS." ) } else -> safeFail(throwable) diff --git a/app/src/main/java/com/lagradost/cloudstream3/network/RequestsHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/network/RequestsHelper.kt index 03ec6ae8..13299002 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/network/RequestsHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/network/RequestsHelper.kt @@ -5,15 +5,12 @@ import androidx.preference.PreferenceManager import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.USER_AGENT import com.lagradost.nicehttp.Requests -import com.lagradost.nicehttp.getCookies import com.lagradost.nicehttp.ignoreAllSSLErrors import okhttp3.Cache import okhttp3.Headers import okhttp3.Headers.Companion.toHeaders import okhttp3.OkHttpClient -import okhttp3.Request import java.io.File -import java.util.concurrent.TimeUnit fun Requests.initClient(context: Context): OkHttpClient {