[java] dbus disconnecting / threaded use of dbus

Colby M White colby.white at utexas.edu
Tue Sep 4 09:40:23 PDT 2012

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.

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.

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):

    public static class TestObserver implements Observer,Topic{
        public TestObserver() throws DBusException{
            // some other stuff
            synchronized (con) {
                con.exportObject("/"+getId(), this);

        public void update(Observable observing, Object arg1) {
            // some other stuff
            try {
                Topic.DataChanged signal=new Topic.DataChanged("/"+getId(),
/*some other stuff*/);
                synchronized (con) {
                    logger.info("Thread "+Thread.currentThread().getId()+"
sent signal "+getId()+" on con "+Arrays.toString(con.getNames()));

            } catch (DBusException e) {

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

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

[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

Any help on dbus disconnections and/or how to get it to tell me why it is
disconnecting would be helpful.

Colby M. White
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20120904/0c43bb6a/attachment.html>

More information about the dbus mailing list