Hi dbus_bus_get_private() failed with error: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory I see that /var/run/dbus/system_bus_socket exists before calling dbus_bus_get_private() logs: netstat -anp | grep dbus : unix 2 [ ACC ] STREAM LISTENING 11681 1/init /var/run/dbus/system_bus_socket unix 3 [ ] STREAM CONNECTED 11831 1574/dbus-daemon unix 3 [ ] STREAM CONNECTED 10907 1574/dbus-daemon unix 3 [ ] STREAM CONNECTED 11830 1574/dbus-daemon unix 3 [ ] STREAM CONNECTED 11833 1574/dbus-daemon /var/run/dbus/system_bus_socket unix 3 [ ] STREAM CONNECTED 11832 1574/dbus-daemon /var/run/dbus/system_bus_socket May 02 07:45:10 ERROR: dbus-send --system --print-reply --reply-timeout=2000 --type=method_call --dest=org.freedesktop.systemd1 /org/freedesktop/systemd1 org. freedesktop.systemd1.Manager.ListUnits : +++ app restarts +++ May 02 07:45:15 ERROR: Failed to open connection to system bus May 02 07:45:15 ERROR: dbus_bus_get_private() failed with error: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory May 02 07:45:15 ERROR: uptime : 07:45:15 up 1 min, 0 users, load average: 1.68, 0.45, 0.15
What process is calling dbus_bus_get_private()? Please show us the relevant code. At around the time that your process fails, does a dbus-send command succeed? The ListUnits invocation that you quoted looks like a useful one to confirm whether a dbus-send command can connect to the system bus. Is the process with the failing call to dbus_bus_get_private() running in a container, chroot or some other unusual environment? You might find that you can get more information by running that process (whatever it is) under strace, or by getting a backtrace with gdb.
thanks. as shown above, dbus-send did not return anything. my app is running normally, not in any container. and i see this issue only some times intermittently. my app's systemd service files has proper dependency on dbus, so it starts after dbus. I also saw some time that dbus_bus_get_private fails without any error msg set. here, I dont understand why error msg says /var/run/dbus/system_bus_socket does not exists when it actually exists. Also do i need to add dependency on any other service in app's systemd service file apart from dbus ? relevant code fron app: 568 dbus_error_init(&error); 569 conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error); 570 571 if (conn == NULL) { 572 ERROR("Failed to open connection to system bus\n"); 573 574 if (dbus_error_is_set (&error)) { 575 ERROR("dbus_bus_get_private() failed with error: %s\n", error.message); 576 assert(0); 577 } 578 579 assert(0); 580 }
Added fewmode details and posted this Q at https://stackoverflow.com/questions/44150226/dbus-bus-get-private-failed-even-though-var-run-dbus-system-bus-socket-exists
(In reply to pcd from comment #2) > as shown above, dbus-send did not return anything. Exit status? stdout? stderr? (I would expect dbus-send to emit messages on stderr and produce a nonzero exit status when it fails, although it's possible that it might also print something on stdout.) > I also saw some time that dbus_bus_get_private fails without any error msg > set. If you can reproduce this under gdb, a backtrace would be useful information. If you can reproduce this under strace, the strace output would be useful information. > here, I dont understand why error msg says /var/run/dbus/system_bus_socket > does not exists when it actually exists. If the connect() call in _dbus_connect_unix_socket() is failing and the result is that error message, then that means connect() is failing with ENOENT. You could confirm whether this is the case by using strace. At that point you're really debugging the interaction between user-space and the kernel, not D-Bus. You haven't said which D-Bus platform, OS distribution name and version, or even kernel you're using (although if you're running systemd, presumably it has to be Linux). > my app's systemd service files has proper dependency on dbus, so it starts > after dbus. If your app is a systemd service, is it using any of the options in the .service file that effectively result in it being in a container? ("systemctl cat your.service" would tell you all the relevant systemd configuration.)
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/dbus/dbus/issues/174.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.