grpc-kotlin icon indicating copy to clipboard operation
grpc-kotlin copied to clipboard

Randomly getting `io.grpc.StatusException: INTERNAL` on all requests

Open outofdate opened this issue 4 years ago • 3 comments
trafficstars

Hey. I wanted to migrate to grpc-kotlin from kroto+(great lib, but as i see it is not updating), so i recently updated all libraries to the last versions(grpc libs to 1.38.0, grpc-kotlin to 1.1.0). Everything goes smooth, except i often randomly get an Exception io.grpc.StatusException: INTERNAL. Can't find source of it and had to think that something is configured wrong in our project, related to coroutines.

After some digging i changed CoroutineStub to BlockingStub and all works perfectly fine.

2021-05-19 13:25:01.133 E/BasePresenter$onError: io.grpc.StatusException: INTERNAL
        at io.grpc.Status.asException(Status.java:551)
        at io.grpc.kotlin.ClientCalls$rpcImpl$1$1$1.onClose(ClientCalls.kt:295)
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:553)
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:68)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:739)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:718)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:98)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

We use grpc on Android.

outofdate avatar May 19 '21 10:05 outofdate

What is your server written in? Is it also using gRPC-Kotlin?

I don't see any way changing your client to gRPC-Kotlin could introduce INTERNAL errors.

lowasser avatar May 25 '21 22:05 lowasser

Hey! Thanks you for your reply. Our backend is using scalapb grpc. I migrated one of our repo to use coroutineStub again and everything seem works with it.

I have only one issue related to new library, that is not poping up on either previous library and with blockingStub, and seems it to be related to my initial problem. We have client authenticator which is updating token if one is expired. As far as i remember i used this code with some adjustments. I believe actual reason of these random errors is related to this class. It seems that this field request initialized with 0 leads to random exceptions at some point.

Caused by: java.lang.IllegalArgumentException: numMessages must be > 0

I doesn't have any idea why does it happens with coroutineStub, but not in other cases. Also if i change this field to 1 it will work, but i don't fully understand on how interceptors in grpc work and what drawbacks it could lead to.

outofdate avatar Jun 08 '21 11:06 outofdate

any updates ? got same issue @outofdate

dbxkoro avatar Jan 03 '22 08:01 dbxkoro