Description
After the merge of apoelstra/rust-jsonrpc#70, which adds SOCKS5 proxy support to the http transport, I am trying to expose this feature through bitcoincore-rpc. While trying to test out the RPC connection I am getting a general SOCKS server failure
error message.
I have added the proxy version of client creation in the integration_test
crate main function
Like this
#[cfg(not(feature = "proxy"))]
let cl = Client::new(&rpc_url, auth).unwrap();
#[cfg(feature = "proxy")]
let cl = Client::new_with_proxy(&rpc_url, auth, "127.0.0.1:9050", None).unwrap();
Tor in my local machine seems to be working
$ systemctl status tor
● tor.service - Anonymizing overlay network for TCP (multi-instance-master)
Loaded: loaded (/lib/systemd/system/tor.service; enabled; vendor preset: enabled)
Active: active (exited) since Sat 2022-09-17 09:51:47 IST; 4h 15min ago
Main PID: 1018 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 18414)
Memory: 0B
CPU: 0
CGroup: /system.slice/tor.service
Sep 17 09:51:47 electra systemd[1]: Starting Anonymizing overlay network for TCP (multi-instance-master)...
Sep 17 09:51:47 electra systemd[1]: Finished Anonymizing overlay network for TCP (multi-instance-master).
Bitcoin core is listening for RPC at 18443
$ sudo netstat -nptl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:18443 0.0.0.0:* LISTEN 166695/bitcoind
tcp 0 0 0.0.0.0:18444 0.0.0.0:* LISTEN 166695/bitcoind
tcp 0 0 127.0.0.1:28332 0.0.0.0:* LISTEN 166695/bitcoind
tcp 0 0 127.0.0.1:18445 0.0.0.0:* LISTEN 166695/bitcoind
tcp 0 0 127.0.0.1:28333 0.0.0.0:* LISTEN 166695/bitcoind
And the running the main
function as below and getting the error
$ RPC_URL=127.0.0.1:18443 RPC_COOKIE=/home/raj/.bitcoin/regtest/.cookie cargo run --features proxy
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running `/home/raj/github-repo/rust-bitcoincore-rpc/target/debug/integration_test`
[DEBUG][bitcoincore_rpc]: JSON-RPC request: getnetworkinfo []
[DEBUG][bitcoincore_rpc]: JSON-RPC failed parsing reply of getnetworkinfo: JsonRpc(Transport(SocketError(Custom { kind: Other, error: "general SOCKS server failure" })))
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: JsonRpc(Transport(SocketError(Custom { kind: Other, error: "general SOCKS server failure" })))', integration_test/src/main.rs:227:35
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I tried googling on the error and most threads are suggesting that this happens because of ISP blocking.. I tried to check my if my tor connection is working and that seems to be working fine
$ curl -x socks5h://localhost:9050 -s https://check.torproject.org/api/ip
{"IsTor":true,"IP":"185.220.101.180"}
Am I missing something for connecting to RPC via Tor? Any suggestion on this would be very much helpful..