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 · May be fixed by #689
Open

Client#connect_relay returns Ok for a nonexistent relay #624

xeruf opened this issue Nov 13, 2024 · 5 comments · May be fixed by #689
Labels
bug Something isn't working
Milestone

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.

yukibtc added a commit that referenced this issue Dec 23, 2024
TODO: description

Closes #624

Signed-off-by: Yuki Kishimoto <[email protected]>
@yukibtc yukibtc added this to the Release v0.38 milestone Dec 23, 2024
yukibtc added a commit that referenced this issue Dec 23, 2024
TODO: description

Closes #624

Signed-off-by: Yuki Kishimoto <[email protected]>
yukibtc added a commit that referenced this issue Dec 23, 2024
TODO: description

Closes #624

Signed-off-by: Yuki Kishimoto <[email protected]>
@yukibtc yukibtc linked a pull request Dec 23, 2024 that will close this issue
yukibtc added a commit that referenced this issue Dec 24, 2024
TODO: description

Closes #624

Signed-off-by: Yuki Kishimoto <[email protected]>
@yukibtc yukibtc modified the milestones: Release v0.38, Release v0.39 Dec 27, 2024
yukibtc added a commit that referenced this issue Dec 28, 2024
Closes #624

Signed-off-by: Yuki Kishimoto <[email protected]>
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

Successfully merging a pull request may close this issue.

2 participants