3 suggestions
Optional improvements
[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).
Details and suggested fix
Both branches of Proxy::Connect() now pass manual_connection=false, moving the detailed connect() to … failed and failed after wait messages from LogInfo to LogDebug(BCLog::NET, ...). The replacement warnings in ConnectThroughProxy() and Session::Hello() contain only the endpoint, so enabling -debug=proxy or -debug=i2p still does not expose the underlying cause. Propagate the failure reason from ConnectToSocket() through the connection helpers and include it in the first LogWarnThenDebug message. This preserves the diagnostic while keeping subsequent failures debug-only. Wait failures and timeouts were already NET debug at the base and are not regressions.
[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).
Details and suggested fix
ConnectThroughProxy() serves the per-network and name proxies, but its LogWarnThenDebug statement has one static flag shared by all endpoints. If endpoint A refuses a connection first, a later refusal from independently configured endpoint B produces only debug output. Fixing A therefore does not ensure that the operator sees a warning identifying B. This follows the helper's intentional once-per-statement semantics, but those semantics collapse separate configured routes here. Key the suppression by endpoint so each route receives one initial warning. The configured set is bounded, and repeated failures of the same endpoint can remain debug-only.
[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).
Details and suggested fix
TestNode enables -debug, so the detailed connect() to … failed line appears whether LogConnectFailure() uses LogInfo or NET debug. The new assertions check the [warning] and [proxy] Cannot connect to proxy messages but reject only another warning. An additional info-level failure therefore goes unnoticed. Start this subtest with -debugexclude=net, keeping the proxy category enabled, and add f"connect() to {proxy}" to unexpected_msgs for the repeated attempt. The intended NET debug message would then be suppressed, while a regression to info logging would fail the assertion.
Background
Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.
Documented decisions
The helper was introduced with statement-scoped semantics: warn “the first time the log line is hit,” then downgrade subsequent occurrences to categorized debug messages. Its stated purpose was to notify administrators of likely configuration problems that degrade functionality without repeatedly logging failures that remote activity can trigger frequently.
This is affirmative historical support for once-per-call-site suppression, rather than suppression keyed to the proxy address or session. It explains the tradeoff: retain an initial operational warning while making repeated occurrences opt-in debugging output. The proposal does not separately discuss recovery followed by another outage.
The preceding Tor-control discussion sought to eliminate repeated connection-failure noise. One proposal called for warn-then-debug on the first disconnect or startup unavailability, an informational message on reconnection, and debug-level retries after the first; another participant explicitly preferred LogWarnThenDebug over debug-only logging.
This supports retaining initial visibility while suppressing retries—the precedent invoked for the proxy changes. However, the wording about the “first” disconnect does not explicitly establish whether a later outage should receive another warning, so that discussion alone does not settle reset semantics.
Source 1 · Source 2 · Source 3
Ralph's inferences
The strongest supported reading is that the chosen helper intentionally provides once-per-call-site suppression for the process lifetime. Its static atomic flag is set on the first invocation and never reset; neither message arguments nor object identity participate in that state.
At the pinned SOCKS call site, different proxy endpoints share the same warning flag. At the pinned I2P Hello call site, different Session instances likewise share one flag. Successful connections do not rearm either flag, so recovery followed by another outage remains debug-level at that call site. This lifetime behavior follows directly from the helper and is consistent with its original “first time the log line is hit” description, although explicit historical deliberation about these lifecycle cases was not found.