Closed zeenix closed 1 year ago
I can't tell much w/o looking at your code but the error indicates a problem on the service side: the process you're talking to is exiting for some reason.
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 18:10
server side is systemd, it's running properly
That's the only indication from the error. I can't help much w/o more information. Can you share your proxy code?
Best if you could create a complete small reproducer so I can just run it on my machine and be able to debug what's going on.
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 18:37
#[zbus::dbus_proxy(
interface = "org.freedesktop.systemd1.Manager",
default_service = "org.freedesktop.systemd1",
default_path = "/org/freedesktop/systemd1"
)]
trait SystemdManager {
fn list_units(&self) -> zbus::Result<Vec<(String, String, String, String, String, String, zvariant::OwnedObjectPath, u32, String, zvariant::OwnedObjectPath)>>;
}
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 18:38
that's the only function I am testing now ... - list_units it works for blocking proxy, but failed for nonblock one
I ran this here and it seems to work perfectly fine here:
use zbus::{dbus_proxy, zvariant::OwnedObjectPath, Connection, Result};
#[dbus_proxy(
interface = "org.freedesktop.systemd1.Manager",
default_service = "org.freedesktop.systemd1",
default_path = "/org/freedesktop/systemd1"
)]
trait SystemdManager {
fn list_units(&self) -> zbus::Result<Vec<(String, String, String, String, String, String, OwnedObjectPath, u32, String, OwnedObjectPath)>>;
}
#[tokio::main]
async fn main() -> Result<()> {
let connection = Connection::session().await?;
let units = SystemdManagerProxy::new(&connection).await?.list_units().await?;
for unit in units {
println!("{}", unit.0);
}
Ok(())
}
Please make sure you're using the latest zbus release: 2.0.1.
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 19:15
yes, I copy ^^ your code and run with package version
zbus = "2.0.1"
tokio = { version = "1.11.0", features = ["macros", "rt", "rt-multi-thread"] }
os
x86_64 x86_64 GNU/Linux unbuntu
same error ChildExit
yes, I copy ^^ your code and run with package version
zbus = "2.0.1" tokio = { version = "1.11.0", features = ["macros", "rt", "rt-multi-thread"] }
I've the same here but tokio version is 1.15.0
.
os
x86_64 x86_64 GNU/Linux unbuntu
same error
ChildExit
Hmm.. I'm completely stumped then. The error is obviously coming from the bus or service side but given that blocking proxy code works fine is very strange.
You're not running any of the components involved in a container, are you? That wouldn't explain how the blocking proxy would work, though.
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 19:36
What do you mean by container
? I am running ubuntu with virtualbox
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 19:38
yes, I am sure the blocking proxy works for list_units
start/get_unit
I have no luck for nonblock proxy with methods ^^
What happens if you take my code exactly here and just change it to using blocking::Connection
and SystemdManagerProxyBlocking
? Does that still work (do remember to remote the async
and tokio::main
from the main
function though)?
What do you mean by
container
? I am running ubuntu with virtualbox
Nevermind then. :)
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 19:40
yes, when test nonblock, I didn't add tokio::main
macro
yes, when test nonblock, I didn't add
tokio::main
macro
You mean, you already tried this and it works w/o errors?
use zbus::{dbus_proxy, zvariant::OwnedObjectPath, blocking::Connection, Result};
#[dbus_proxy(
interface = "org.freedesktop.systemd1.Manager",
default_service = "org.freedesktop.systemd1",
default_path = "/org/freedesktop/systemd1"
)]
trait SystemdManager {
fn list_units(&self) -> zbus::Result<Vec<(String, String, String, String, String, String, OwnedObjectPath, u32, String, OwnedObjectPath)>>;
}
fn main() -> Result<()> {
let connection = Connection::session()?;
let units = SystemdManagerProxyBlocking::new(&connection)?.list_units()?;
for unit in units {
println!("{}", unit.0);
}
Ok(())
}
If so, I'm out of ideas. Maybe upgrading your tokio helps (just a blind guess that's unlike to work but I'm no other ideas anymore).
For the record, on my Fedora both versions work flawlessly.
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 19:46
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 22:23
Oh ... Man, I see why, change
Connection::session()
to
Connection::system()
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 22:24
so , what's the difference session
vs system
?
dbus newbie ...
weird. That doesn't explain why the blocking code works, at all. Were you using system
with the blocking code?
so , what's the difference
session
vssystem
? dbus newbie ...
From our book:
Typically, a Linux system has a system bus, and a session bus. The latter is per-user. It is also possible to have private buses or no bus at all (i-e direct peer-to-peer communication instead).
In GitLab by @li.yu.sh0211 on Jan 14, 2022, 01:36
yes, for blocking one I was using system
So you didn't use the code I had provided then. 🤦♂️ It would have saved some time if you had. Anyway, glad to hear you got it working.
In GitLab by @li.yu.sh0211 on Jan 14, 2022, 02:31
actually, your code is using session https://gitlab.freedesktop.org/dbus/zbus/-/issues/243#note_1218819 it doesn't work at least for ubuntu
In GitLab by @li.yu.sh0211 on Jan 14, 2022, 02:38
And your official doc is using session as well for SystemdManagerProxy
https://dbus.pages.freedesktop.org/zbus/client.html#properties
In GitLab by @li.yu.sh0211 on Jan 14, 2022, 02:39
The problems is no longer block / nonblocking, but session vs system instead :smile:
Yes, my code was using session in both version but you reported that my blocking code works, while it didn't. Obviously, you didn't try my (blocking) code but assumed it's the same as yours.
Anyway, good that you got it sorted.
As for code sample using session, I will change it to use system. It works fine on Fedora so we never noticed before that it's not working on other distros. Many thanks for reporting!
mentioned in commit 0e128ec40e65cdc45c74f70bffff11a955443c56
In GitLab by @li.yu.sh0211 on Jan 13, 2022, 17:35
Here is error details
same method working for blocking proxy though, need help ...