Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to connect to a custom/private address #361

Closed
qingxiang-jia opened this issue May 27, 2023 · 4 comments · Fixed by #363
Closed

Failed to connect to a custom/private address #361

qingxiang-jia opened this issue May 27, 2023 · 4 comments · Fixed by #363
Labels
documentation Improvements or additions to documentation zbus Issues/PRs related to zbus crate

Comments

@qingxiang-jia
Copy link

First, thank you for the help on #354. I revised my code to something like below:

#[tokio::main]
async fn main() {
    play_with_zbus().await;
}

async fn play_with_zbus() {
    let address = get_ibus_address().expect("Faild to get IBus address.");
    
    println!("IBus address: {}", address);
    
    let conn = ConnectionBuilder::address(Address::Unix(address.into()))
        .expect("Failed to get a connection to the session bus.")
        .auth_mechanisms(&[AuthMechanism::External])
        .build()
        .await
        .expect("Failed to build a DBus connection.");
}

I would get output like:

IBus address: unix:path=/home/lee/.cache/ibus/dbus-5pdegSP4,guid=31b5004906b205dd7d4638846472476b
thread 'main' panicked at 'Failed to build a DBus connection.: InputOutput(Os { code: 2, kind: NotFound, message: "No such file or directory" })', src/main.rs:65:10

I think the address is correct and I was able to use the same address to get it connected with the other DBus library. Maybe I missed something. Thanks!

@zeenix
Copy link
Contributor

zeenix commented May 27, 2023

Try passing the address string directly to the ConnectionBuilder::address instead. It takes a generic argument for a reason. 😊

@zeenix
Copy link
Contributor

zeenix commented May 27, 2023

Also you don't need to specify authentication mechanism.

@zeenix zeenix closed this as completed May 27, 2023
@qingxiang-jia
Copy link
Author

That worked! Thank you!

@zeenix
Copy link
Contributor

zeenix commented May 28, 2023

That worked! Thank you!

glad to hear. I think we should add an example in the docs.

@zeenix zeenix reopened this May 28, 2023
@zeenix zeenix added documentation Improvements or additions to documentation zbus Issues/PRs related to zbus crate labels May 28, 2023
zeenix added a commit to zeenix/zbus that referenced this issue May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation zbus Issues/PRs related to zbus crate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants