paritytech / subxt

Interact with Substrate based nodes in Rust or WebAssembly
Other
425 stars 248 forks source link

Remove the need for a default port on the URL #644

Closed KarimJedda closed 2 years ago

KarimJedda commented 2 years ago

The following returns an error:

subxt metadata --url="wss://rpc.polkadot.io" -f bytes > metadata.scale

Error: 
   0: Networking or low-level protocol error: Invalid URL: No port number in URL (default port is not supported)
   1: Invalid URL: No port number in URL (default port is not supported)

This works:

subxt metadata --url="wss://rpc.polkadot.io:443" -f bytes > metadata.scale

My question is: Is there a specific reason why the port number is required?

Thanks a lot

jsdw commented 2 years ago

No explicit reason; I had a bit of a dig and it turns out that the reason is because jsonrpsee's HttpTransportClient wants there to be an explicit port on the Uri.

@niklasad1 would it make sense to default to 80/443 for http/https (or ws/wss) in jsonrpsee if no port is given, rather than expect one?

niklasad1 commented 2 years ago

https://github.com/hyperium/http/issues/509

It's not possible to know whether the port number was missing or if the port number was faulty in that API but maybe it's possible to workaround that.

montekki commented 2 years ago

fwiw this also does not work:

subxt metadata -f bytes --url="wss://moonbeam.api.onfinality.io/public-ws:443" > meta.scale
Error:
   0: Networking or low-level protocol error: Invalid URL: No port number in URL (default port is not supported)
   1: Invalid URL: No port number in URL (default port is not supported)
KarimJedda commented 2 years ago

@montekki, the port needs to be on the host part of the URL and not the full path ie:

wss://moonbeam.api.onfinality.io:443/public-ws should be the right parameter.

montekki commented 2 years ago

@KarimJedda ah, true, thanks

niklasad1 commented 2 years ago

@montekki yeah that one is tricky done that too many times :)

jsdw commented 2 years ago

Given that this issue is really one of us not knowing whether an invalid port or no port was provided (see https://github.com/hyperium/http/issues/509), I'm going to close this for now since I don't think it's worth trying to do anything here at the mo (we'd have to do some parsing ourselves or something).