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

Bug: invalid URL 'http://[fd01::4]:8332': invalid port #792

Closed
schildbach opened this issue Nov 5, 2022 · 6 comments · Fixed by #794
Closed

Bug: invalid URL 'http://[fd01::4]:8332': invalid port #792

schildbach opened this issue Nov 5, 2022 · 6 comments · Fixed by #794
Labels
bug Something isn't working

Comments

@schildbach
Copy link
Contributor

Describe the bug
If the bitcoind address resolves to an IPv6 address, an invalid URL is being constructed: http://[fd01::4]:8332
Either that, or the URL is in fact valid but some component within electrs can't deal with it and outputs the message:

Bug: invalid URL 'http://[fd01::4]:8332': invalid port

Electrs version
electrs 0.9.10 running within Docker 20.10.12 under Ubuntu 22.04.1 LTS (all up to date)

To Reproduce
Steps to reproduce the behavior:

  1. Configure and start electrs in an IPv6 network
  2. See error, electrs exits with code 1

Expected behavior
An IPv6 connection to bitcoind, just like with IPv4.

Configuration
The relevant part of the config is probably:

    environment:
      - ELECTRS_DAEMON_RPC_ADDR=bitcoind:8332
      - ELECTRS_DAEMON_P2P_ADDR=bitcoind:8333
@schildbach schildbach added the bug Something isn't working label Nov 5, 2022
@schildbach
Copy link
Contributor Author

Investigating into the Rust dependency chain, I've stumbled upon these issues:

apoelstra/rust-jsonrpc#62
apoelstra/rust-jsonrpc#63

The line that prints the error message is probably this one:

https://github.com/apoelstra/rust-jsonrpc/blob/master/src/simple_http.rs#L199

I'm still looking into where the "invalid port" reason message is coming from.

@schildbach
Copy link
Contributor Author

It seems like an outdated version of jsonrpc without IPv6 support is being pulled via Cargo dependencies:

electrs v0.9.10 (/home/electrs)
├── bitcoincore-rpc v0.16.0
│   ├── jsonrpc v0.12.0

jsonrpc 0.13.0 would have IPv6 support – is it possible to overload versions of transitive dependencies with Cargo? Then this would probably be an easy fix.

@Kixunil
Copy link
Contributor

Kixunil commented Nov 5, 2022

It should be possible to patch it - add this to Cargo.toml:

[patch.crates-io.bitcoincore-rpc]
git = "https://github.com/rust-bitcoin/rust-bitcoincore-rpc"
# May minimize the chance of breaking, you can try to leave it out to get even more recent bitcoincore-rpc
branch = "d2959ec11b951f304a538b2bbab67d999cdb3426"

@schildbach
Copy link
Contributor Author

@Kixunil Thanks! The branch doesn't seem to exist, but I simply removed it (so it used bde02d7f / master) and it seems to work.

romanz added a commit that referenced this issue Nov 6, 2022
@schildbach
Copy link
Contributor Author

This bug is still present in version 0.9.11.

@romanz
Copy link
Owner

romanz commented Jan 6, 2023

Indeed, we need a new release of bitcoincore-rpc crate: rust-bitcoin/rust-bitcoincore-rpc#253

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.

3 participants