square/okhttp

OkHttp 5.1 not executing requests

Closed this issue · 4 comments

After updating our Android app from 4.12 to 5.1, we have seen the client doesn't start executing requests.

It happens rarely and most seen immediately after the app is launched.

The client doesn't output any logs and doesn't time out after the connection or read timeouts have expired.

It just hangs.

I have tried running the following code when the issue happens:

    fun printOkHttpStatus() {
        Timber.d("OkHttp connectionPool count = ${okHttpClient.connectionPool.connectionCount()}")
        Timber.d("OkHttp idleConnectionCount = ${okHttpClient.connectionPool.idleConnectionCount()}")
        Timber.d("OkHttp queuedCallsCount = ${okHttpClient.dispatcher.queuedCallsCount()}")
        Timber.d("OkHttp runningCalls count = ${okHttpClient.dispatcher.runningCalls().size}")
        viewModelScope.launch {
            withContext(Dispatchers.IO) {
                okHttpClient.connectionPool.evictAll()
                okHttpClient.dispatcher.cancelAll()
            }
        }
    }

The client doesn't recover after that and it outputs:

OkHttp connectionPool count = 0
OkHttp idleConnectionCount = 0
OkHttp queuedCallsCount = 1
OkHttp runningCalls count = 1

I think the connection pool count of zero could be a problem.
But I don't know the internals of OkHttp.

The only known workaround is to kill the app and lunch again.

The client is configured without specifying dispatcher and connection pool. So they are default.

I realise that you would want more info and I would like to give to that. But I need some guidance on how to get it.

With the event listener I only get a couple of:

10:55:24.391  D  0,000 callStart
10:55:53.722  D  0,000 callStart

Can I put a break point somewhere?

Youll need to provide more code and context.

I have been debugging and found that it gets stuck in the interceptor chain on an interceptor that calls com.google.android.gms.security.ProviderInstaller.installIfNeeded(context) which never completes.
So it isn't an issue with the client. Closing this issue.