Crash with OkHttp error: `IllegalStateException: cannot make a new request...`
rafaelekol opened this issue · comments
Getting this error on app start after upgrading library from 1.15.0 to 1.16.0
implementation(platform("com.walletconnect:android-bom:1.16.0"))
implementation 'com.walletconnect:sign'
implementation 'com.walletconnect:android-core'
Crash log:
Process: io.horizontalsystems.bankwallet.dev, PID: 6566
java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close()
at okhttp3.internal.connection.RealCall.enterNetworkInterceptorExchange(RealCall.kt:237)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:55)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.pandulapeter.beagle.logOkHttp.OkHttpInterceptor.intercept(OkHttpInterceptor.kt:51)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.walletconnect.android.internal.common.di.CoreNetworkModuleKt$coreAndroidNetworkModule$1$6.invoke$lambda$0(CoreNetworkModule.kt:96)
at com.walletconnect.android.internal.common.di.CoreNetworkModuleKt$coreAndroidNetworkModule$1$6$$ExternalSyntheticLambda0.intercept(Unknown Source:2)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.walletconnect.android.internal.common.di.CoreNetworkModuleKt$coreAndroidNetworkModule$1$4.invoke$lambda$0(CoreNetworkModule.kt:68)
at com.walletconnect.android.internal.common.di.CoreNetworkModuleKt$coreAndroidNetworkModule$1$4$$ExternalSyntheticLambda0.intercept(Unknown Source:2)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:205)
Function coreAndroidNetworkModule()
in CoreNetworkModule.kt file contains multiple calls chain.proceed()
which can cause such error.
I couldn't reproduce this error with your sample app.
It may be the same issue as described here
The newest version is 1.21.0. Can you upgrade and see if this still persists?
@jakubuid I tried to update until version 1.21.0.
But it didn't help. I am getting same error.
Can you provide reproduction steps?
@jakubuid
Inside this class com.walletconnect.android.internal.common.di.CoreNetworkModule
I added 2 lines of code to reproduce
crash that is happening in our project.
@Suppress("LocalVariableName")
@JvmSynthetic
fun coreAndroidNetworkModule(serverUrl: String, connectionType: ConnectionType, sdkVersion: String, timeout: NetworkClientTimeout? = null) = module {
val DEFAULT_BACKOFF_SECONDS = 5L
...
single(named(AndroidCommonDITags.FAIL_OVER_INTERCEPTOR)) {
Interceptor { chain ->
val request = chain.request()
try {
val host = request.url.host
//I added these 2 lines
chain.proceed(request)
throw SocketException("test")
when {
shouldFallbackRelay(host) -> chain.proceed(request.newBuilder().url(get<String>(named(AndroidCommonDITags.RELAY_URL))).build())
shouldFallbackPush(host) -> chain.proceed(request.newBuilder().url(getFallbackPushUrl(request.url.toString())).build())
shouldFallbackVerify(host) -> chain.proceed(request.newBuilder().url(getFallbackVerifyUrl(request.url.toString())).build())
else -> chain.proceed(request)
}
} catch (e: Exception) {
if (isFailOverException(e)) {
when (request.url.host) {
DEFAULT_RELAY_URL.host -> fallbackRelay(request, chain)
DEFAULT_PUSH_URL.host -> fallbackPush(request, chain)
DEFAULT_VERIFY_URL.host -> fallbackVerify(request, chain)
else -> chain.proceed(request)
}
} else {
chain.proceed(request)
}
}
}
}
...
@rafaelekol thank you! We'll look into this ASAP
Hi, any updates on this issue?
@rafaelekol we're still investigating a solution to enable failover for both our Http client and websocket client
@rafaelekol are you able to tell us if you saw this issue in a Debug build or on a Release build?
@Talhaali00 This crash is steadily happens when I try to increase your Release library higher than 1.15.0.
We suspect that issue lies in combination of other network libraries that we use in our App with your SDK.
@Talhaali00 Any progress on this bug?
This issue is holding us from updating your SDK in our wallet.
Hello @rafaelekol
We've been able to focus time to resolving this issue. There's a PR #1365 where I've able to make sure that the interceptor isn't leaving a response open when switching over during the failover logic. We'll be releasing a new version this week with this fix
@Talhaali00 thats great news 👍🏼