MystenLabs / sui

Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by the Move programming language
https://sui.io
Apache License 2.0
6.22k stars 11.2k forks source link

Invalid URL: Port number is missing in the URL when using Ankr’s Sui Mainnet RPC URL #19382

Closed 273million closed 1 month ago

273million commented 1 month ago

I’m experiencing a “Port number is missing in the URL” error when trying to connect to Sui Mainnet using Ankr’s RPC URL. I have tried different configurations, including appending :443 to the URL and switching from HTTPS to HTTP, but the issue persists.

Thank you for your help, saw also others having the issue, but couldn't see the solution there.

Steps to Reproduce Issue

$ sui client new-address ed25519

Config file ["/Users/./.sui/sui_config/client.yaml"] doesn't exist, do you want to connect to a Sui Full node server [y/N]?y

Sui Full node server URL (Defaults to Sui Testnet if not specified) : https://rpc.ankr.com/sui/your-api-key...

Environment alias for [https://rpc.ankr.com/sui/your-api-key...] : ankr Select key scheme to generate keypair (0 for ed25519, 1 for secp256k1, 2: for secp256r1): 0

Networking or low-level protocol error: Invalid Url: Port number is missing in the URL

Expected Result

Connection to Sui Mainnet without issues.

Actual Result

Networking or low-level protocol error: Invalid Url: Port number is missing in the URL

System Information

•   Sui CLI version: 1.34.0-f28674511c84
•   Compiler: Apple clang version 15.0.0
•   OS: macOS arm64
stefan-mysten commented 1 month ago

Thanks @273million for the report. This is indeed an issue, because of the underlying jsonrpsee library used for the JSON RPC server which requires a port :|. Could you try to manually add this RPC url in the client.yaml config file under ~/.sui/sui_config folder? Not sure if that would work or not, but trying locally on my machine that seems to do the trick.

For example, showing just the envs part.

envs:
  - alias: testnet
    rpc: "https://fullnode.testnet.sui.io:443"
    ws: ~
  - alias: ankr-testnet
    rpc: "https://rpc.ankr.com:443/sui/API_KEY"
    ws: ~
273million commented 1 month ago

Thank you @stefan-mysten !

I manually added the RPC in the client.yaml config as suggested, but unfortunately, it still doesn’t work. It seems to work when testnet is the active environment, but when I switch to my Ankr RPC, I encounter the same error:

Networking or low-level protocol error: Invalid Url: Port number is missing in the URL

Caused by:
    Invalid Url: Port number is missing in the `URL`

Here’s the config I’m using:

    envs:
  - alias: testnet
    rpc: "https://fullnode.testnet.sui.io:443"
    ws: ~
    basic_auth: ~
  - alias: ankr
    rpc: "https://rpc.ankr.com/sui/api-key:443"
    ws: ~
    basic_auth: ~

active_env: ankr
stefan-mysten commented 1 month ago

Thanks @273million. Please note that the port number should be after .com instead of after api-key.

It should be

    envs:
  - alias: testnet
    rpc: "https://fullnode.testnet.sui.io:443"
    ws: ~
    basic_auth: ~
  - alias: ankr
    rpc: "https://rpc.ankr.com:443/sui/api-key"
    ws: ~
    basic_auth: ~
273million commented 1 month ago

Thank you!

stefan-mysten commented 1 month ago

My pleasure, and sorry for the headache!