Connection closed err in code. Dbus-send works fine though

PookieMonster pookie at
Tue Jul 26 09:02:48 PDT 2011

I'm trying to get the basic PIN agent (agent.c) that ships with Bluez to run
on my system.  Right now it's returning after the DBus call to get the
default bluetooth adapter in this chunk of code:

	msg = dbus_message_new_method_call("org.bluez", "/",
					"org.bluez.Manager", "DefaultAdapter");

	if (!msg) {
		printf("\n[Bluetooth] Can't allocate new method call\n");
		return NULL;


	reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);


	if (!reply) {
			"[Bluetooth] Can't get default adapter\n");
		if (dbus_error_is_set(&err)) {
			fprintf(stderr, "[Bluetooth] %s\n", err.message);
		return NULL;

reply is coming back NULL and err is set so I get this output:

[Bluetooth] Can't get default adapter
[Bluetooth] Connection is closed

However, if I run dbus-send on the same machine, I get back the information
I expect
# dbus-send --print-reply --system --dest=org.bluez --type=method_call /
method return sender=:1.0 -> dest=:1.9 reply_serial=2
   object path "/org/bluez/146/hci0"

Any ideas what would cause it to work in one place and not the other.  I am
trying to integrate this code into a larger application, but this would be
the only code that is concerned with DBus so I was assuming I'd be fine
(perhaps mistakenly assuming)


View this message in context:
Sent from the Free Desktop - dbus mailing list archive at

More information about the dbus mailing list