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

NoAddressFound on some endpoints #337

Closed
chevdor opened this issue May 25, 2021 · 6 comments
Closed

NoAddressFound on some endpoints #337

chevdor opened this issue May 25, 2021 · 6 comments

Comments

@chevdor
Copy link
Contributor

chevdor commented May 25, 2021

This issue could be related to #320.

I am using WsClientBuilder::default().build(&url) to connect to various endpoints.
Most endpoints work, that includes:

  • wss://kusama.elara.patract.io
  • wss://westend.elara.patract.io

The following however, fail with Transport(NoAddressFound):

  • wss://rococo.elara.patract.io
  • wss://47.241.106.95 (manually resolved IP of the above)
@niklasad1
Copy link
Member

niklasad1 commented May 25, 2021

Are you using latest master or running on 0.2.0-alpha.x on crates.io?

On master(using the native certificate store) I get the following:

[2021-05-25T19:47:25Z DEBUG rustls::anchors] add_pem_file processed 128 valid and 0 invalid certs
[2021-05-25T19:47:25Z DEBUG rustls::client::hs] No cached session for DNSNameRef("rococo.elara.patract.io")
[2021-05-25T19:47:25Z DEBUG rustls::client::hs] Not resuming any session
[2021-05-25T19:47:26Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_128_GCM_SHA256
[2021-05-25T19:47:26Z DEBUG rustls::client::tls13] Not resuming
[2021-05-25T19:47:26Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: []
[2021-05-25T19:47:26Z DEBUG rustls::client::hs] ALPN protocol is None
[2021-05-25T19:47:26Z DEBUG rustls::client::tls13] Ticket saved
[2021-05-25T19:47:26Z DEBUG jsonrpsee_ws_client::transport] Failed to connect to sockaddr: 47.241.106.95:443 with err: Rejected { status_code: 405 }
Error: Networking or low-level protocol error: Couldn't find any IP address for this hostname

Thus, the dns name was resolved to an IP address but the server refused the request, status code 405.
The error message could be improved though.

@chevdor
Copy link
Contributor Author

chevdor commented May 25, 2021

I am using:

jsonrpsee = {git = "https://github.com/paritytech/jsonrpsee", features = ["full"]}

and that should be rather "fresh":

git+https://github.com/paritytech/jsonrpsee#a60896e16c192b2fb4f3efea166ebcb4d9d1ba3b

@niklasad1
Copy link
Member

niklasad1 commented May 25, 2021

Ok, right,

Can you run it with RUST_LOG="debug" cargo run --example ws and provide the logs?

I still think it's the server that rejects the connection because that endpoint is not allowed for the "public" or something but that's just a pure guess.

Still, it doesn't work with websocat either so doesn't seem to our fault except a faulty error message.

[2021-05-25T21:48:39Z DEBUG rustls::anchors] add_pem_file processed 128 valid and 0 invalid certs
[2021-05-25T21:48:40Z DEBUG rustls::client::hs] No cached session for DNSNameRef("rococo.elara.patract.io")
[2021-05-25T21:48:40Z DEBUG rustls::client::hs] Not resuming any session
[2021-05-25T21:48:40Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_128_GCM_SHA256
[2021-05-25T21:48:40Z DEBUG rustls::client::tls13] Not resuming
[2021-05-25T21:48:40Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: []
[2021-05-25T21:48:40Z DEBUG rustls::client::hs] ALPN protocol is None
[2021-05-25T21:48:40Z DEBUG rustls::client::tls13] Ticket saved
[2021-05-25T21:48:40Z DEBUG soketto::handshake::client] handshake send "GET / HTTP/1.1\r\nHost: rococo.elara.patract.io\r\nUpgrade: websocket\r\nConnection: upgrade\r\nSec-WebSocket-Key: PsOFc8AjEgEWB7zT0yeWhw==\r\nSec-WebSocket-Version: 13\r\n\r\n"
[2021-05-25T21:48:40Z DEBUG soketto::handshake::client] Response { version: Some(1), code: Some(405), reason: Some("Method Not Allowed"), headers: [Header { name: "Content-Length", value: [54, 49] }, Header { name: "Content-Type", value: [116, 101, 120, 116, 47, 112, 108, 97, 105, 110, 59, 32, 99, 104, 97, 114, 115, 101, 116, 61, 117, 116, 102, 45, 56] }, Header { name: "Date", value: [84, 117, 101, 44, 32, 50, 53, 32, 77, 97, 121, 32, 50, 48, 50, 49, 32, 50, 49, 58, 52, 56, 58, 52, 48, 32, 71, 77, 84] }, Header { name: "Server", value: [67, 97, 100, 100, 121] }] }
[2021-05-25T21:48:40Z DEBUG soketto::handshake::client] headers: {"Content-Length": "61", "Server": "Caddy", "Date": "Tue, 25 May 2021 21:48:40 GMT", "Content-Type": "text/plain; charset=utf-8"}
[2021-05-25T21:48:40Z DEBUG soketto::handshake::client] reason: Method Not Allowed
[2021-05-25T21:48:40Z DEBUG jsonrpsee_ws_client::transport] Failed to connect to sockaddr: 47.241.106.95:443 with err: Rejected { status_code: 405 }
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Transport(NoAddressFound)', examples/ws.rs:41:55

@chevdor
Copy link
Contributor Author

chevdor commented May 26, 2021

Here is the requested test, I was about to say it works but the response seems to be truncated actually.

RUST_LOG="debug" cargo run --example ws
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/examples/ws`
[2021-05-26T07:39:25Z DEBUG jsonrpsee_ws_client::transport] send: {"jsonrpc":"2.0","method":"say_hello","id":0,"params":null}
[2021-05-26T07:39:25Z DEBUG jsonrpsee_ws_client::client] [backend]: recv method_call JsonRpcResponse { jsonrpc: TwoPointZero, result: String("lo"), id: Some(RawValue(0)) }
r: "lo"

@chevdor
Copy link
Contributor Author

chevdor commented May 26, 2021

Here are the details using my example.

$ POLKADOT_WS=wss://rococo.elara.patract.io RUST_LOG="debug" cargo run --example ws_polkadot 
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/examples/ws_polkadot`
Connecting to "wss://rococo.elara.patract.io"
[2021-05-26T07:43:22Z DEBUG rustls::client::hs] No cached session for DNSNameRef("rococo.elara.patract.io")
[2021-05-26T07:43:22Z DEBUG rustls::client::hs] Not resuming any session
[2021-05-26T07:43:22Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_128_GCM_SHA256
[2021-05-26T07:43:22Z DEBUG rustls::client::tls13] Not resuming
[2021-05-26T07:43:22Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: []
[2021-05-26T07:43:22Z DEBUG rustls::client::hs] ALPN protocol is None
[2021-05-26T07:43:22Z DEBUG rustls::client::tls13] Ticket saved
[2021-05-26T07:43:22Z DEBUG jsonrpsee_ws_client::transport] Failed to connect to sockaddr: 47.241.106.95:443 with err: Rejected { status_code: 405 }
Error: Networking or low-level protocol error: Couldn't find any IP address for this hostname

Caused by:
    Couldn't find any IP address for this hostname
    
Code example

use jsonrpsee::ws_client::WsClientBuilder;
use std::env;

fn get_ws_node() -> String {
	env::var("POLKADOT_WS").unwrap_or("ws://localhost:9944".to_string())
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
	env_logger::init();

	let url = String::from(get_ws_node());
	println!("Connecting to {:?}", &url);
	let client = WsClientBuilder::default().build(&url).await?;
	assert!(client.is_connected());
    println!("connected");
	Ok(())
}

@niklasad1
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants