[java] dbus disconnecting / threaded use of dbus

Matthew Johnson dbus at matthew.ath.cx
Tue Sep 4 16:07:29 PDT 2012

On Tue Sep 04 11:40, Colby M White wrote:
> I am attempting to use the java bindings for dbus and am encountering a
> disconnecting problem. When I send a signal, the connection is disconnected
> with out given me much of a reason as to why. Part of the issue is it
> doesn't happen all the time, just when it feels like it. That's making it
> hard to reproduce.

Hi, that's really strange - it definitely shouldn't do that.

> So my main question: What are the possible reasons that a connection would
> decide to disconnect (other then hitting the DBusConnection.disconnect()
> method, which I confirmed is never being called in my code)? If I knew what
> could cause a disconnection, then it would narrow my search.

Generally sending malformed stuff. Aside from strings I really should be
stopping you sending anything illegal though.

> One unique aspect to my setup is that I'm sending multiple signals, each by
> its own thread. As far as I can tell, I've done this in a thread-safe
> manner. When the signals are sent, they are sent in a synchronized block.
> Here's a quick stream-lined glance at my class (Topic is a basic
> DBusInterface that only has a signal):

it should already be thread-safe. Sending any message just appends it to a
queue, which a background thread pops from and does the actual send.

> Is there something about using this java binding in a threaded environment
> that I'm missing? Are there some dbus-thread guidelines/safe practices? I'm
> not entirely sure my threaded environment and the disconnections are
> related (or at least my tests aren't showing that they are), but the very
> nature of threads makes it hard to know. My gut tells me they probably are
> related.

Nothing in that snippet looks obvious. Do you have a testcase you can reproduce

> I recompiled my dbus jar with debug enabled and here is what is happening
> after I send the signal. As you can see it writes, then disconnects right
> after.
> [org.freedesktop.dbus.AbstractConnection$_sender.run()] Got message:
> DataChanged(0,7) { Path=>..., Interface=>dbus.topics.Topic,
> Member=>DataChanged, Signature=>a{sv} } { { //the contents of my map//} }
> [org.freedesktop.dbus.Message.append()] Appending sig: a{sv} data: [{ //the
> contents of my map//}]
> [org.freedesktop.dbus.MessageWriter.writeMessage()] <= DataChanged(0,7) {
> Path=>..., Interface=>dbus.topics.Topic, Member=>DataChanged,
> Signature=>a{sv} } { { //the contents of my map//} }
> [org.freedesktop.dbus.MessageWriter.writeMessage()] Writing all 102 buffers
> simultaneously to Unix Socket
> [org.freedesktop.dbus.DBusConnection.disconnect()] Disconnecting
> DBusConnection
> Any help on dbus disconnections and/or how to get it to tell me why it is
> disconnecting would be helpful.

Can you try changing the log levels by adding a debug.conf in the working
directory? Try:


or (warning, lots of output) ALL=VERBOSE

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 835 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20120905/50cf6299/attachment.pgp>

More information about the dbus mailing list