net: Warn only once when a proxy or the I2P proxy is unreachable #36969

Open
fjahr wants to merge 2 commits from 2026-11-i2p-proxy-log into master AGit
fjahr commented 2026-11-24 19:47:41 +00:00 (Migrated from github.com)

There seems to be consensus in #36759 to use LogWarnThenDebug when the Tor control port can't be reached as this makes such cases much less noisy. This pull aligns SOCKS5 proxies (-proxy, -onion) and the I2P SAM proxy (-i2psam) with that, making them also less noisy.

Until now every failed attempt logged the connect() failure at info level, and I2P additionally logged "Couldn't listen" as an error. Now the first failure is logged as a warning and later ones only at debug level.

There seems to be consensus in #36759 to use `LogWarnThenDebug` when the Tor control port can't be reached as this makes such cases much less noisy. This pull aligns SOCKS5 proxies (`-proxy`, `-onion`) and the I2P SAM proxy (`-i2psam`) with that, making them also less noisy. Until now every failed attempt logged the `connect()` failure at info level, and I2P additionally logged "Couldn't listen" as an error. Now the first failure is logged as a warning and later ones only at debug level.
DrahtBot commented 2026-11-24 19:47:51 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36904 (log: Remove trailing and embedded newlines from log messages by maflcko)
  • #36434 (http: support unix sockets by pinheadmz)
  • #36257 (qa: assert_equal -> assert_true/assert_false by hodlinator)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36969 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36969.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36969#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36904](https://github.com/bitcoin/bitcoin/pull/36904) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36904.svg"></sub> (log: Remove trailing and embedded newlines from log messages by maflcko) * [#36434](https://github.com/bitcoin/bitcoin/pull/36434) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36434.svg"></sub> (http: support unix sockets by pinheadmz) * [#36257](https://github.com/bitcoin/bitcoin/pull/36257) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36257.svg"></sub> (qa: assert_equal -> assert_true/assert_false by hodlinator) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

🔵 Suggestion · The first proxy/SAM warning omits the connection error

With default logging, refused TCP connections and missing or inaccessible Unix sockets now produce an initial SOCKS/SAM warning that identifies the endpoint but omits the OS error needed to distinguish these causes.

Location: src/netbase.cpp:685 (head).

🔵 Suggestion · One SOCKS endpoint consumes the warning for every configured endpoint

With distinct -proxy and -onion or per-network endpoints, a connection failure on one can suppress the other's first warning at default logging.

Location: src/netbase.cpp:813 (head).

🔵 Suggestion · The proxy test misses repeated info-level connect() failures

The new proxy subtest would still pass if Proxy::Connect() reverted to manual_connection=true, leaving the repeated info-level connection failures that this PR aims to suppress.

Location: test/functional/feature_proxy.py:512 (head).

Review coverage was incomplete.


Reviewed: 058e26fdddfb · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:301f8fac66b8cbe87114981d6600f15187695a2edf245458a232c3958e920add:3329223fb40bbbe44124b0523f0fa08f23650d06836368f60e45a38d2db02971 --> <!-- ralph-base:74f3ed9021e853aa14a402ed0ceef78544c5b4a7 --> <!-- ralph-head:058e26fdddfb1acda0013ed66ba2ce1c02489919 --> <!-- ralph-case:3eb67461506a1076803d1ab4e742dde128b5922ceeaa15f41a207d5a7012db7d --> **🔵 Suggestion · The first proxy/SAM warning omits the connection error** With default logging, refused TCP connections and missing or inaccessible Unix sockets now produce an initial SOCKS/SAM warning that identifies the endpoint but omits the OS error needed to distinguish these causes. Location: [`src/netbase.cpp:685`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/058e26fdddfb1acda0013ed66ba2ce1c02489919/src/netbase.cpp#L685>) (head). **🔵 Suggestion · One SOCKS endpoint consumes the warning for every configured endpoint** With distinct `-proxy` and `-onion` or per-network endpoints, a connection failure on one can suppress the other's first warning at default logging. Location: [`src/netbase.cpp:813`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/058e26fdddfb1acda0013ed66ba2ce1c02489919/src/netbase.cpp#L813>) (head). **🔵 Suggestion · The proxy test misses repeated info-level `connect()` failures** The new proxy subtest would still pass if `Proxy::Connect()` reverted to `manual_connection=true`, leaving the repeated info-level connection failures that this PR aims to suppress. Location: [`test/functional/feature_proxy.py:512`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/058e26fdddfb1acda0013ed66ba2ce1c02489919/test/functional/feature_proxy.py#L512>) (head). Review coverage was incomplete. <!-- Review tier: standard --> --- Reviewed: [`058e26fdddfb`](<https://git.fish.foo/bitcoin/bitcoin/commit/058e26fdddfb1acda0013ed66ba2ce1c02489919>) · [Review report](<https://review.fish.foo/report/36969-058e26fdddfb1acda0013ed66ba2ce1c02489919-3075-1.html>) · [Previous reports](<https://review.fish.foo/traces/36969/>) [permalink](<https://review.fish.foo/report/36969-058e26fdddfb1acda0013ed66ba2ce1c02489919-3075-1.html>)
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36969
No description provided.