[systemd-devel] sd-bus connections & authentication timeout

Stanislav Angelovič angelovic.s at gmail.com
Mon Mar 20 15:37:08 UTC 2017


Hi,

We use sd-bus for DBus IPC in our own applications. Some applications of
ours cause the dbus daemon to issue "Connection has not authenticated soon
enough, closing it" message, leading to the
org.freedesktop.DBus.Error.Timeout error at the peer side when the
connection is used for an IPC call.

The situation is the following:
1. We have a DBus client application.
2. A connection is created using sd_bus_open_system() on application
startup.
3. The connection is kept open and unused (i.e. no other sd-bus functions
invoked on it).
4. After 30 seconds, we get the above-mentioned authentication timeout
message from the dbus daemon, and any attempt to issue calls against a
service via this connection fails with immediate timeout error as mentioned
above. However, if the call is made before the 30 seconds authentication
timeout, the dbus daemon prints nothing and the call succeeds, just like
any subsequent call, even if issued after 1 hour from the first one.

Is that correct behavior? We would like to open dbus connections at
application startup, and use it for communication at any time later,
depending on user actions. Is there something we are missing?

And a side suggestion: If we want to close a connection that has not been
used for any IPC call at all, after some struggling we have realized that
sd_bus_unref() is not enough, as there is a lingering DBus.Hello reply
which keeps the reference count on that connection, leading to lingering
connections. sd_bus_flush_close_unref() is needed instead. That behavior
could be mentioned in the documentation, e.g. at
http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html in the
reference client implementation, to save others from pain.

Thanks a lot,

Stanislav.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20170320/5f538229/attachment.html>


More information about the systemd-devel mailing list