Linux 对自定义方法使用dbus发送到地址127.0.0.1

Linux 对自定义方法使用dbus发送到地址127.0.0.1,linux,dbus,Linux,Dbus,我正在尝试让dbus send--address处理我为自己编写的自定义方法(com.example.Test.TestMethod)的地址127.0.0.1端口10010。这本身并不是一件有用的事情,但我正在尝试完成更多的事情,这是一个测试步骤 首先,我确信我的测试方法是正确的。对于我的方法,在本地使用系统总线成功: $ dbus-send --system --print-reply --type=method_call --dest=com.example.Test /com/examp

我正在尝试让
dbus send--address
处理我为自己编写的自定义方法(
com.example.Test.TestMethod
)的地址127.0.0.1端口10010。这本身并不是一件有用的事情,但我正在尝试完成更多的事情,这是一个测试步骤


首先,我确信我的测试方法是正确的。对于我的方法,在本地使用系统总线成功:

$ dbus-send --system --print-reply --type=method_call --dest=com.example.Test /com/example/Test com.example.Test.TestMethod string:foo
method return sender=:1.0 -> dest=:1.17 reply_serial=2
   string "returning foo"

其次,使用
--address
失败(我不明白为什么失败):

dbus监视器
完全不显示任何内容:

$ DBUS_VERBOSE=1 dbus-monitor --system
(nothing)

第三,在
org.freedesktop.DBus.Hello
上使用
--address
成功。我不知道为什么会成功,而我的方法失败了:

$ dbus-send --address=tcp:host=127.0.0.1,port=10010 --print-reply --type=method_call --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Hello
method return sender=org.freedesktop.DBus -> dest=:1.15 reply_serial=1
   string ":1.15"

我对配置文件
/etc/dbus-1/system.conf
做了一些修改:

  <auth>ANONYMOUS</auth>
  <allow_anonymous/>

<listen>tcp:host=127.0.0.1,port=10010</listen>

    <allow send_destination="com.example.Test"/>
    <allow own="com.example.Test"/>
失败案例(
com.example.Test.TestMethod
):


我还使用
dbus\u VERBOSE=1
启动了调试模式
dbus守护进程
,但我在任何地方都找不到输出。它不在系统日志中。我可能没有调试版本,但我发现这不太可能,因为
dbus send
dbus monitor
显然是调试变体


我在会话总线上做过同样的实验,结果也一样


版本信息:

$ dbus-daemon --version
D-Bus Message Bus Daemon 1.6.8

$ cat /etc/debian_version
7.6
我的最终目标是使用D-bus在计算机之间传递消息。让
dbussend--address
为本地案例工作只是我前进的第一步


更新日期:2014年10月16日:我能够让它工作。解决方案是违反直觉的

有两个要求

您必须使用系统总线进行通信。 您必须设置会话总线地址环境变量

$ DBUS_SESSION_BUS_ADDRESS=tcp:host=192.168.56.101,port=10010 dbus-send --print-reply --type=method_call --dest=com.example.Test /com/example/Test com.example.Test.TestMethod string:foo

我认为这是因为dbus守护进程要求提供数据,而您的客户机不知道如何读取它。你能试着用wireshirk甩掉整个握手吗?(或者,您可以使用我的脚本,但它可能需要一些源代码调整)

[dbus/dbus-transport-socket.c(873):do_reading] Disconnected from remote app
[dbus/dbus-transport.c(502):_dbus_transport_disconnect] start
[dbus/dbus-transport-socket.c(1017):socket_disconnect] 
[dbus/dbus-transport-socket.c(76):free_watches] start
[dbus/dbus-watch.c(628):dbus_watch_set_data] Setting watch fd -1 data to data = (nil) function = (nil) from data = (nil) function = (nil)
[dbus/dbus-watch.c(628):dbus_watch_set_data] Setting watch fd -1 data to data = (nil) function = (nil) from data = (nil) function = (nil)
[dbus/dbus-transport-socket.c(98):free_watches] end
[dbus/dbus-transport.c(513):_dbus_transport_disconnect] end
$ dbus-daemon --version
D-Bus Message Bus Daemon 1.6.8

$ cat /etc/debian_version
7.6
$ DBUS_SESSION_BUS_ADDRESS=tcp:host=192.168.56.101,port=10010 dbus-send --print-reply --type=method_call --dest=com.example.Test /com/example/Test com.example.Test.TestMethod string:foo