2
votes

I've been struggling all day with the following issue with gRPC on Android when trying to make an RPC call to a python RPC server running on my machine (on the same network).

My android gRPC android client compiles and runs, however, I get the following error message on the client (and silence on the python server):

io.grpc.StatusRuntimeException: UNAVAILABLE
Caused by: java.io.IOException: PROTOCOL_ERROR invalid settings id: -509 

The full stack-trace reads:

05-06 18:39:01.133 5018-5302/com.example.android.cimi I/SyncAdapter: Failed... : 
io.grpc.StatusRuntimeException: UNAVAILABLE
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:227)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:208)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:141)
at com.example.android.cimi.CimiSyncerGrpc$CimiSyncerBlockingStub.getHouseholdTimestamps(CimiSyncerGrpc.java:209)
at com.example.android.cimi.SyncAdapter.onPerformSync(SyncAdapter.java:130)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259)
Caused by: java.io.IOException: PROTOCOL_ERROR invalid settings id: -509
at io.grpc.okhttp.internal.framed.Http2.ioException(Http2.java:589)
at io.grpc.okhttp.internal.framed.Http2.access$200(Http2.java:47)
at io.grpc.okhttp.internal.framed.Http2$Reader.readSettings(Http2.java:304)
at io.grpc.okhttp.internal.framed.Http2$Reader.nextFrame(Http2.java:162)
at io.grpc.okhttp.OkHttpClientTransport$ClientFrameHandler.run(OkHttpClientTransport.java:868)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
05-06 18:39:01.139 5018-5018/com.example.android.cimi I/SyncService: Service destroyed                                                                         

When shutting off the server, I get a different error, so something else must be going on.

I'm using the following versions: io.grpc:protoc-gen-grpc-java:1.3.0 com.google.protobuf:protoc:3.0.0

Things I've tried:

  1. Downgrading to grpc 1.0.0
  2. Downgrading Android studio
  3. Tried python 2&3
  4. Connecting from a python client works!

How else could I debug this? Is there any way to get more meaningful exceptions? Is there a way to make the server more verbose?

Any help would be greatly appreciated!

1

1 Answers

2
votes

I've narrowed it down to a problem with the python gRPC server by confirming that the call works when using a Java server instead.

It turns out it must have been related to recent gRPC/protobuf python packages (just installed via pip install, must have grabbed the most recent ones):

The following sequence of commands for downgrading the gRPC installation solved the issue:

cd /usr/lib/python2.7/site-packages
rm -rf packaging* 
rm -rf pyparsing*
pip2 install protobuf==3.0.0
pip2 install grpcio==1.0.0
pip2 install grpcio-tools==1.0.0