ArrayIndexOutOfBounds on RPC time out
This is occurring in Android when a RPC request to the app times out (easy to simulate with a breakpoint)
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 at io.deepstream.RpcHandler.handle(RpcHandler.java:159) at io.deepstream.Connection$3.run(Connection.java:223) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)
The handler receives this message: P¬E¬INVALID_RPC_CORRELATION_ID¬ unexpected state for rpc..
This causes an app crash which can't be caught.
Hi @jamesalexscott, I tried to recreate this issue with the following code.
public static void main(String[] args) throws URISyntaxException {
DeepstreamClient client2 = new DeepstreamClient("localhost:6020");
client2.login();
client2.rpc.provide("timeout", new RpcRequestedListener() {
@Override
public void onRPCRequested(String rpcName, Object data, RpcResponse response) {
System.out.println("onRpcRequested");
}
});
DeepstreamClient client = new DeepstreamClient("localhost:6020");
client.login();
RpcResult res = client.rpc.make("timeout", "test");
System.out.println(res.getData());
}
The output of which is:
onRpcRequested
RESPONSE_TIMEOUT
This is correct. Is there any more info you can provide to reproduce this?
Hi @AlexBHarley, apologies for the slow response. I've been away
I'm not sure if it's limited to Android, but it's quite easy to reproduce in Android.
In the onRPCRequested, if you put a Thread.sleep(5000) and then try and send a response it will cause an App crash. Even with try/catch