我正在尝试在ProxyBusObject接口上调用远程AllJoyn方法,但出现ErrorReplyBusException。我似乎在API指南或参考文档中找不到与此有关的任何信息。任何帮助将非常感激。这是代码和错误日志。提前致谢。
private void connectToClient(String wellKnownName) {
mProxyObj = mBus.getProxyBusObject(wellKnownName, OBJECT_PATH, BusAttachment.SESSION_ID_ANY, new Class[]{MyBusInterface.class});
mMyBusInterface = mProxyObj.getInterface(MyBusInterface.class);
String test = mMyBusInterface.doSomething();
if (test == null) {
Log.i(TAG, "Null");
} else {
Log.i(TAG, test);
}
}
错误日志:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: tesi.groupcast, PID: 16789
java.lang.reflect.UndeclaredThrowableException
at $Proxy3.doSomething(Unknown Source)
at tesi.groupcast.MainService.connectToClient(MainService.java:188)
at tesi.groupcast.MainService.update(MainService.java:219)
at tesi.groupcast.GroupCastApp.notifyObservers(GroupCastApp.java:104)
at tesi.groupcast.GroupCastApp.newSeedNode(GroupCastApp.java:115)
at tesi.groupcast.MainGUI$1.onEditorAction(MainGUI.java:85)
at android.widget.TextView.onEditorAction(TextView.java:4483)
at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:139)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:304)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5294)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
Caused by: org.alljoyn.bus.ErrorReplyBusException: org.alljoyn.Bus.Blocked
at org.alljoyn.bus.ProxyBusObject.methodCall(Native Method)
at org.alljoyn.bus.ProxyBusObject.access$300(ProxyBusObject.java:35)
at org.alljoyn.bus.ProxyBusObject$Handler.invoke(ProxyBusObject.java:264)
at java.lang.reflect.Proxy.invoke(Proxy.java:397)
at $Proxy3.doSomething(Unknown Source)
at tesi.groupcast.MainService.connectToClient(MainService.java:188)
at tesi.groupcast.MainService.update(MainService.java:219)
at tesi.groupcast.GroupCastApp.notifyObservers(GroupCastApp.java:104)
at tesi.groupcast.GroupCastApp.newSeedNode(GroupCastApp.java:115)
at tesi.groupcast.MainGUI$1.onEditorAction(MainGUI.java:85)
at android.widget.TextView.onEditorAction(TextView.java:4483)
at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:139)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:304)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5294)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
最佳答案
错误是因为总线不知道应该创建哪个ProxyObject,因为总线没有连接到任何BusObject。
这是因为您需要在调用代理对象之前加入会话。致电status = mBus.joinSession(busName, port, sessionID, sessionOpts, new SessionListener());
并在调用getProxyObject
方法和其他方法之前检查加入会话的状态。
关于java - AllJoyn ErrorReplyBusException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36695329/