Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Android, ManagedChannel is no more reusable (10 requests max with 1 request per second) #10572

Closed
eltanardo opened this issue Sep 22, 2023 · 8 comments
Assignees
Labels

Comments

@eltanardo
Copy link

eltanardo commented Sep 22, 2023

What version of gRPC-Java are you using?

1.58.0

What is your environment?

- Client side
RouteGuide example for Android, tagged v1.58.0
Tested with Android 9 to Android 13

- Server side
RouteGuide server example from grpc python tagged v1.58.0, linux

What did you expect to see?

I expect to be able to reuse the same ManagedChannel for each grpc call

What did you see instead?

After approximately 10 requests in 10 seconds, the channel is no more usable. I have to "exit router guide" then "start router guide", because the channel is no more usable

- On Android client side

io.grpc.StatusRuntimeException: UNAVAILABLE: Refused stream
Rst Stream
	at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:268)
	at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:249)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:167)
	at io.grpc.routeguideexample.RouteGuideGrpc$RouteGuideBlockingStub.getFeature(RouteGuideGrpc.java:361)
	at io.grpc.routeguideexample.RouteGuideActivity$GetFeatureRunnable.getFeature(RouteGuideActivity.java:201)
	at io.grpc.routeguideexample.RouteGuideActivity$GetFeatureRunnable.run(RouteGuideActivity.java:189)
	at io.grpc.routeguideexample.RouteGuideActivity$GrpcTask.doInBackground(RouteGuideActivity.java:156)
	at io.grpc.routeguideexample.RouteGuideActivity$GrpcTask.doInBackground(RouteGuideActivity.java:141)
	at android.os.AsyncTask$2.call(AsyncTask.java:333)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:764)

Steps to reproduce the bug

  • On Android client side
    Launch RouteGuide
    Enter server host and port
    "start route guide"
    Click 1 time per second on "Get Feature".

With grpc-java version from v1.29.0 to v1.46.1, it works. Above version v1.46.1, it fails

- On Linux Python server side
No error

@larry-safran
Copy link
Contributor

The error indicates that the endpoint has received a HEADERS frame that caused its concurrent stream limit to be exceeded. It is surprising to me that the limit is only 10.

Are you reading the returned values from the future or just letting the results accumulate?

@eltanardo
Copy link
Author

In order to exclude a problem with my implementation (Android <-> Linux C++), I reproduced the behavior with the examples provided by grpc-java Android java 1.58.0 and grpc python 1.58.0.

On client side, I have the issue with Android platform only, not the java desktop version. If I switch to version 1.46.1, the ManagedChannel manages the connection well.

What I do on RouteGuide example is to click each second on the button "Get Feature".

@ejona86
Copy link
Member

ejona86 commented Oct 31, 2023

The 10 is probably because Python limits the number of workers to 10 in the example.

@ejona86
Copy link
Member

ejona86 commented Nov 3, 2023

@temawi, this does line up with the upgrades to appcompat. Seems that should have been low-risk. I wonder if the Android libraries changed something that means RPCs aren't getting closed now when they previously were.

@temawi
Copy link
Contributor

temawi commented Dec 18, 2023

I just tried running the 1.58.0 Android route guide client against 1.58.0 Go server and no amount of clicking is reproducing the problem. This seems to point the finger at the Python server.

@eltanardo maybe you can confirm you also see the same thing? Getting a Go server running is straightforward, after installing Go:

git clone --branch v1.58.0 https://github.com/grpc/grpc-go.git
cd examples/route_guide
go run server/server.go

The server will run on port 50051

@eltanardo
Copy link
Author

eltanardo commented Dec 20, 2023

@temawi , using v1.46.1 v1.58.1 android client,
I have reproduced the same behavior with Golang (just have to change the binding address that was stuck on loopback :-) ) and C++ servers. On the other hand, no issue observed with the java server.
v1.58.1.webm

@temawi
Copy link
Contributor

temawi commented Jan 16, 2024

@eltanardo v1.46.1 is old at this point, why did you use that version? Can you reproduce it with 1.58.0 client and 1.58.0 Go server?

@temawi
Copy link
Contributor

temawi commented Feb 6, 2024

No updates on this one so maybe the issue got resolved? I will close this but it can be reopened if further discussion is needed.

@temawi temawi closed this as completed Feb 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants