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

Tons of Socks5() connect to x.x.x.x:8333 failed: connection refused-messages when i use TOR - why? #29759

Closed
1 task done
kosuodhmwa opened this issue Mar 28, 2024 · 21 comments

Comments

@kosuodhmwa
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behaviour

Gets tons of Socks5() connect to x.x.x.x:8333 failed: connection refused-messages

Expected behaviour

No messages like that

Steps to reproduce

  • install tor via apt-get

  • add that to /etc/tor/torrc file:
    ControlPort 9051
    CookieAuthentication 1
    CookieAuthFileGroupReadable 1

  • restart tor service

  • add that to ~/.bitcoin/bitcoin.conf file:
    proxy=127.0.0.1:9050
    listen=1
    bind=127.0.0.1

  • start bitcoind service

Relevant log output

Many lines like that:

Socks5() connect to x.x.x.x:8333 failed: connection refused

How did you obtain Bitcoin Core

Compiled from source

What version of Bitcoin Core are you using?

Most current

Operating system and version

Debian 12.5.x

Machine specifications

Oracle VirtualBox VM, Debian 12.5.x on Windows 10 Pro x64 Host System

@kosuodhmwa
Copy link
Author

Installed as described on https://en.bitcoin.it/wiki/Setting_up_a_Tor_hidden_service AND

1.) "usermod -a -G debian-tor BITCOIN_USER" instead of "usermod -a -G tor BITCOIN_USER"

2.) Then a OS restart after that user / group permission change thing

@kosuodhmwa
Copy link
Author

(BITCOIN_USER = root)

@kosuodhmwa
Copy link
Author

Maybe the problem is that IPv6 is disabled via sysctl.conf on that system?

@kosuodhmwa
Copy link
Author

Similar problem here?
#25094

@kosuodhmwa
Copy link
Author

image

@kosuodhmwa
Copy link
Author

Nobody knows what the problem is?

@pinheadmz
Copy link
Member

What exact commit did you compile from? Does it include #29649 ?

@kosuodhmwa
Copy link
Author

How can i get the version number from the source i've got from master GIT repo i've compiled?

@pinheadmz
Copy link
Member

pinheadmz commented Mar 29, 2024 via email

@mzumsande
Copy link
Contributor

mzumsande commented Apr 1, 2024

I also get these errors sometimes when running with Tor. While they appear on some outgoing connection attempts, other connections are successful, so there seems to be nothing wrong on my end fundamentally. While a timout does not lead to a log entry in debug.log, answers from the SOCKS5 proxy with "general failure" and "connection refused" are logged, and it is not clear to me when which of the three happens.

So I wonder if this happens every time and you can't make successful connections, or only sporadically (in which case the only problem might be overzealous logging).

@vasild
Copy link
Contributor

vasild commented Apr 2, 2024

As @mzumsande mentioned above, some errors like these are normal because they are printed whenever we fail to connect to a Tor peer. Not all Tor peers are online all the time. Does bitcoin-cli getpeerinfo show that you have at least one outbound connection to a Tor node? With some filtering: bitcoin-cli getpeerinfo |jq 'map(select(.inbound == false and .network == "onion")) |map({connection_type: .connection_type, addr: .addr, network: .network})'.

If you cannot establish any connection to a Tor node, then there is a real problem in your setup.

Socks5() connect to x.x.x.x:8333 failed: connection refused

This error comes from the Socks5 proxy (aka the Tor daemon) if it cannot connect to the destination we asked for. Do you get only IP addresses in those messages (x.x.x.x) or also onion addresses (e.g. ydvbxdzs6w5wefifiqsqntpbd7tliofenqih5hlnz34546fvy4ab7iid.onion)?

There is an inconsistency wrt logging connection failures: IPv4 and IPv6 connection failures are logged only if running with -debug=net:

LogPrint(BCLog::NET, "%s\n", error_message);

LogPrint(BCLog::NET, "connection attempt to %s timed out\n", dest_str);

whereas Tor connection failures are logged as errors unconditionally:
LogPrintf("Socks5() connect to %s:%d failed: %s\n", strDest, port, Socks5ErrorString(pchRet2[1]));

PS this is different from #25094 - the current issue is about errors when trying to establish outbound connections. That issue is about not being able to accept incoming connections (because we couldn't communicate properly to the Tor daemon where to redirect those incoming connections to).

@mzumsande
Copy link
Contributor

For me, the Tor daemon also behaves inconsistently (Ubuntu).
If I attempt to make a connection to one and the same non-reachable node (with addnode and onetry), I sometimes get a IntrRecvError::Timeout (which is not logged unconditionally), and sometimes get an error (Socks5() connect to x.x.x.x:8333 failed: general failure). I haven't been able to detect a pattern which of the two happens when, it looks random to me.
From reading the code, I get the impression that the original assumption was that if the peer is not online, the Socks5 proxy returns a timeout instead of a failure - which isn't always the case for me.

@kosuodhmwa
Copy link
Author

The source code from the master branch i've compiled is:
root@debian-12-btc-node:~/bitcoin# git rev-parse HEAD gives me the following output:
0fa9f17

@kosuodhmwa
Copy link
Author

0fa9f17332a6d9b2eb6e3d9f9102bfd2d9c6f516

@kosuodhmwa
Copy link
Author

kosuodhmwa commented Apr 3, 2024

image
Now i saw that i also have message like that:

2024-04-03T20:43:47Z Socks5() connect to 77.7.121.181:8333 failed: general failure

Will start "bitcoind" now with filtering for that Tor Socks5 messages: ./bitcoind | grep Socks5

@kosuodhmwa
Copy link
Author

kosuodhmwa commented Apr 3, 2024

"Do you get only IP addresses in those messages (x.x.x.x) or also onion addresses (e.g. ydvbxdzs6w5wefifiqsqntpbd7tliofenqih5hlnz34546fvy4ab7iid.onion)?"

No, only for IP addresses as shown on post above. (other kind of message, but same host / ip and also same port) @vasild

@kosuodhmwa
Copy link
Author

sn

@kosuodhmwa
Copy link
Author

Maybe it's an idea to check these servers (they will be listed via console output) via "telnet [IP_ADDRESS] 8333"...

If i dont get an anwser from telnet (TCP), then the problem is on these hosts / servers. If i get an answser, there is a problem on my side

vasild added a commit to vasild/bitcoin that referenced this issue May 8, 2024
It is expected to have some Bitcoin nodes unreachable some of the time.
A failure to connect to an IPv4 or IPv6 node is already properly logged
under category=net/severity=debug. Do the same when a connection fails
when using a SOCKS5 proxy. This could be either to an .onion address or
to an IPv4 or IPv6 address (via a Tor exit node).

Related: bitcoin#29759
@vasild
Copy link
Contributor

vasild commented May 8, 2024

There is an inconsistency wrt logging connection failures...

Addressed in #30064

@kosuodhmwa
Copy link
Author

ok thx

vasild added a commit to vasild/bitcoin that referenced this issue May 31, 2024
It is expected to have some Bitcoin nodes unreachable some of the time.
A failure to connect to an IPv4 or IPv6 node is already properly logged
under category=net/severity=debug. Do the same when a connection fails
when using a SOCKS5 proxy. This could be either to an .onion address or
to an IPv4 or IPv6 address (via a Tor exit node).

Related: bitcoin#29759
@kosuodhmwa
Copy link
Author

closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants