我已经编写了一些代码来利用KryoNet的RMI功能。我已经按照这些示例进行了操作,这一切都在我的计算机上运行良好。
但是,当从Android应用程序中运行相同的代码时,我得到了" com.esotericsoftware.kryonet.rmi.TimeoutException"。这是完整的堆栈跟踪:
com.esotericsoftware.kryonet.rmi.TimeoutException: Response timed out: xyz.test.lib.capabilities.IServerControl.getServerUptime
at com.esotericsoftware.kryonet.rmi.ObjectSpace$RemoteInvocationHandler.invoke(ObjectSpace.java:408)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy0.getServerUptime(Unknown Source)
at xyz.test.clientandroid.testClient.init(TestClient.java:70)
at xyz.test.clientandroid.MainActivity$1.run(MainActivity.java:36)
可能导致这种情况的原因是什么?
我已将日志级别更改为STRACE,并且与服务器的对话看起来好像一切正常:
DEBUG: [kryonet] Connection 2 sent TCP: PacketLogin (26)
TRACE: [kryonet] Connection listener added: com.esotericsoftware.kryonet.rmi.ObjectSpace$RemoteInvocationHandler$1
TRACE: [kryonet] Client listener added.
TRACE: [kryo] Write class 15: com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethod
DEBUG: [kryo] Write: com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethod
TRACE: [kryo] Object graph complete.
TRACE: [kryo] Read class 16: com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethodResult
TRACE: [kryo] Read field: objectID (com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethodResult)
TRACE: [kryo] Read: 2
TRACE: [kryo] Read field: responseID (com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethodResult)
TRACE: [kryo] Read: -63
TRACE: [kryo] Read field: result (com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethodResult)
TRACE: [kryo] Read class 7: long
TRACE: [kryo] Read: 182710
DEBUG: [kryo] Read: com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethodResult
TRACE: [kryo] Object graph complete.
TRACE: [kryonet] Connection 2 sent TCP: InvokeMethod (9)
TRACE: [kryonet] Connection 2 received TCP: InvokeMethodResult
DEBUG: [kryonet] Connection 2 sent: IServerControl#getServerUptime() (9)
TRACE: [kryo] Read class 16: com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethodResult
TRACE: [kryo] Read field: objectID (com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethodResult)
TRACE: [kryo] Read: 2
TRACE: [kryo] Read field: responseID (com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethodResult)
TRACE: [kryo] Read: -63
TRACE: [kryo] Read field: result (com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethodResult)
TRACE: [kryo] Read class 7: long
TRACE: [kryo] Read: 182710
DEBUG: [kryo] Read: com.esotericsoftware.kryonet.rmi.ObjectSpace$InvokeMethodResult
TRACE: [kryo] Object graph complete.
TRACE: [kryonet] Connection 2 received TCP: InvokeMethodResult
我认为没有必要附上任何代码,因为这似乎不是问题所在。如果有人想看到它,我会很乐意发布它。
我使用的Android SDK是版本23.
谢谢