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

[ws client]: Handshake failed connecting to valid URL #306

Closed
chevdor opened this issue May 10, 2021 · 2 comments
Closed

[ws client]: Handshake failed connecting to valid URL #306

chevdor opened this issue May 10, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@chevdor
Copy link
Contributor

chevdor commented May 10, 2021

Considering the following example (not in the repo):

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(())
}

This will succeed:

POLKADOT_WS=wss://rpc.polkadot.io c run --example ws_polkadot  

But this will fail despite the endpoint to be valid and up:

POLKADOT_WS=wss://polkadot.api.onfinality.io/public-ws c run --example ws_polkadot
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/examples/ws_polkadot`
Connecting to "wss://polkadot.api.onfinality.io/public-ws"
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
@chevdor chevdor added the bug Something isn't working label May 10, 2021
@niklasad1
Copy link
Member

niklasad1 commented May 10, 2021

I could reproduce this, the server rejected handshake not exactly sure why:

[2021-05-10T14:15:07Z DEBUG rustls::client::hs] No cached session for DNSNameRef("polkadot.api.onfinality.io")
[2021-05-10T14:15:07Z DEBUG rustls::client::hs] Not resuming any session
[2021-05-10T14:15:07Z DEBUG rustls::client::hs] Using ciphersuite TLS13_CHACHA20_POLY1305_SHA256
[2021-05-10T14:15:07Z DEBUG rustls::client::tls13] Not resuming
[2021-05-10T14:15:07Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: []
[2021-05-10T14:15:07Z DEBUG rustls::client::hs] ALPN protocol is None
[2021-05-10T14:15:07Z DEBUG rustls::client::tls13] Ticket saved
[2021-05-10T14:15:07Z DEBUG rustls::client::tls13] Ticket saved
[2021-05-10T14:15:07Z DEBUG jsonrpsee_ws_client::transport] Failed to connect to sockaddr: 34.249.193.87:443 with err: Rejected { status_code: 404 }

websocat works for this endpoint so it's bug somewhere, not sure where though

@niklasad1 niklasad1 changed the title Some websocket url fail connecting [ws client]: Handshake failed connecting to valid URL May 11, 2021
@niklasad1
Copy link
Member

Closed by #335

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