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

Client#connect_relay returns Ok for a nonexistent relay #624

Open
xeruf opened this issue Nov 13, 2024 · 5 comments
Open

Client#connect_relay returns Ok for a nonexistent relay #624

xeruf opened this issue Nov 13, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@xeruf
Copy link
Contributor

xeruf commented Nov 13, 2024

Describe the bug
When I call connect_relay for a relay that does not exist such as ws://localhost:1234, I get Ok

Expected behavior
I get an Error

Build environment

  • Library: sdk v0.36
  • Language: rust
  • Language version: v1.82
  • Tag/commit:
  • OS+version: arch linux
@xeruf xeruf added the bug Something isn't working label Nov 13, 2024
@yukibtc
Copy link
Member

yukibtc commented Nov 13, 2024

I can't reproduce it. I receive RelayNotFound error

@xeruf
Copy link
Contributor Author

xeruf commented Nov 13, 2024

Example:

use nostr_sdk::prelude::*;

#[tokio::main]
async fn main() {
    let client = Client::new(Keys::generate());
    let result = client.add_relay("ws://localhost:3333").await;
    println!("{:?}", result);
    let result = client.connect_relay("ws://localhost:3333").await;
    println!("{:?}", result);
}

Running target/debug/examples/relay-test
Ok(true)
Ok(())

@yukibtc
Copy link
Member

yukibtc commented Nov 13, 2024

Example:

use nostr_sdk::prelude::*;

#[tokio::main]
async fn main() {
    let client = Client::new(Keys::generate());
    let result = client.add_relay("ws://localhost:3333").await;
    println!("{:?}", result);
    let result = client.connect_relay("ws://localhost:3333").await;
    println!("{:?}", result);
}

Running target/debug/examples/relay-test
Ok(true)
Ok(())

You are adding it with Client::add_relay so it can't return the RelayNotFound error.

@xeruf
Copy link
Contributor Author

xeruf commented Nov 14, 2024

How can I add it thus that I get an error if the connection fails?

@yukibtc
Copy link
Member

yukibtc commented Nov 14, 2024

How can I add it thus that I get an error if the connection fails?

Ah ok, now I've understood. It try to establish connection in another thread and automatically reconnect.

I can consider adding a try_connect method, that return an error if fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants