'grpc-java rpcs blocking each other
I am trying to use grpc-java inside an Android application. When it runs on an Android emulator or if I use a C++ client (the server is also C++), everything works just fine. However, when I use on on my physical device it is different. If a large amount of information is sent to the server then it seems to sometimes (nearly every time) 'block' any other rpcs that try to complete.
For example if I start a unary rpc to send a 50Mb file, then I start another unary rpc that is sending <1Kb, the <1Kb rpc will a lot of the time complete after the 50Mb file. Even if the large file takes minutes to send.
Someone has mentioned something similar to this before here. I tried both answers. First I tried adding an executor. Then I tried using a custom NameResolver (described here) with the same addresses to provide multiple connections to the same server inside the one channel. Neither seems to make a difference.
Is Android itself doing something with the connection? I didn't see anything in the networking documentation about it stopping multiple connections. Also I tried previous versions of grpc and they all seem to do the same thing.
If I make multiple channels and use the channels for different rpcs, this is not an issue. However, the docs say that creating channels is expensive so I would prefer to use that as a last resort. Also it would be difficult to deal with bi-directional streams that need to do more than download or upload one thing at a time. This doesn't seem like it should be an issue considering Google recommends grpc for android, so am I missing something?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
