<br><br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 20, 2017, 16:37 Stanislav Angelovič <<a href="mailto:angelovic.s@gmail.com">angelovic.s@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">Hi,<br class="gmail_msg"><br class="gmail_msg"></div>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.<br class="gmail_msg"><br class="gmail_msg"></div>The situation is the following:<br class="gmail_msg"></div><div class="gmail_msg">1. We have a DBus client application.<br class="gmail_msg"></div>2. A connection is created using sd_bus_open_system() on application startup.<br class="gmail_msg"></div>3. The connection is kept open and unused (i.e. no other sd-bus functions invoked on it).<br class="gmail_msg"></div>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.<br class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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?<br class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 <a href="http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html" class="gmail_msg" target="_blank">http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html</a> in the reference client implementation, to save others from pain.<br class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Thanks a lot,<br class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Stanislav.<br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div></div></div></div></div></div></div></div>
_______________________________________________<br class="gmail_msg">
systemd-devel mailing list<br class="gmail_msg">
<a href="mailto:systemd-devel@lists.freedesktop.org" class="gmail_msg" target="_blank">systemd-devel@lists.freedesktop.org</a><br class="gmail_msg">
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a></blockquote></div><div><br></div><div>You could try calling sd_bus_process(bus, NULL) in a loop while it returns >0 so that the initial hello is handled.</div><div><br></div><div>However, that only gets you past the hello. To be a good D-Bus client, you should poll the connection and process any unexpected incoming messages. The best approach depends on what your app and your use of sd-bus looks like.</div>