Can someone please explain how this setting works, as I need to test its behavior? If I set the value to something very small (1 or even 0) I do not see any indication that the timeout value has been observed. For example, with torrc as follows, if I run tor -f ./torrc CircuitBuildTimeout 0 a circuit is built as normal. If I disable the network and run the command, tor hangs for over 2 minutes (indefinitely?). Shouldn’t I at least see a [warn] or [err] message in tor’s log output?
SocksPort 9150
ControlPort 9151
Many thanks.
Tor 0.4.7.16 on Linux Debian bookworm
CircuitBuildTimeout NUM
Try for at most NUM seconds when building circuits.
If the circuit isn’t open in that time, give up on it.
If LearnCircuitBuildTimeout is 1, this value serves as the
initial value to use before a timeout is learned.
If LearnCircuitBuildTimeout is 0, this value is the
only value used. (Default: 60 seconds)
If you don’t see any effect of this setting maybe you haven’t set LearnCicuitBuildTimeout 0. I just tested it and i got a warning about a low value when using CircuitBuildTimeout 1. When set to 0 tor just seems to ignore it. Have you enabled debug logs?
I understand from man tor that LearnCicuitBuildTimeout is set to 1 by default, but I get the same result with it set to 1 or 0. I am not running tor as daemon so I see the logs in stdout. I get no warning with a CircuitBuildTimeout value of 0, or 1. If my network is disconnected, to deliberately prevent a circuit build, the last 2 lines from the logs are as follows when I run tor -f ./torrc CircuitBuildTimeout 1
Jul 20 13:22:00.000 [notice] Starting with guard context "default"
Jul 20 13:24:40.000 [notice] Failed to find node for hop #1 of our path. Discarding this circuit.
This seems to indicate tor has waited 2 minutes and 40 seconds to abandon the circuit build - not at all what I expected. I’d really like to understand the expected behavior in this situation, as I need to test a circuit timeout for an application I’m building and so far setting it to any value seems to have no effect. Can someone maybe point me at the relevant test for CircuitBuildTimeout functionality in tor’s source code?
If i run tor without a network connection it doesn’t try to build circuits but fails while trying to select reachable guards. But if i throttle my connection heavily i get messages like this
Thanks, that was helpful. So I’ve done the same an throttled my connection so bootstrapping takes several minutes. I then added LearnCicuitBuildTimeout 0 to my torrc and ran tor -f ./torrc CircuitBuildTimeout 1. I now see the [warn] CircuitBuildTimeout is shorter (1 seconds).. message. The relevant part of my logs tell me tor took a couple of minutes to build a circuit and bootstrap.
Jul 21 13:44:56.000 [notice] Bootstrapped 0% (starting): Starting
Jul 21 13:44:57.000 [notice] Starting with guard context "default"
Jul 21 13:44:58.000 [notice] Bootstrapped 5% (conn): Connecting to a relay
Jul 21 13:44:58.000 [notice] Bootstrapped 10% (conn_done): Connected to a relay
Jul 21 13:45:00.000 [notice] Bootstrapped 14% (handshake): Handshaking with a relay
Jul 21 13:45:07.000 [notice] Bootstrapped 15% (handshake_done): Handshake with a relay done
Jul 21 13:45:07.000 [notice] Bootstrapped 75% (enough_dirinfo): Loaded enough directory info to build circuits
Jul 21 13:45:07.000 [notice] Bootstrapped 90% (ap_handshake_done): Handshake finished with a relay to build circuits
Jul 21 13:45:07.000 [notice] Bootstrapped 95% (circuit_create): Establishing a Tor circuit
Jul 21 13:46:50.000 [notice] Bootstrapped 100% (done): Done
I did not see the info message you posted. I suspect I’m misunderstanding the purpose of the CircuitBuildTimeout setting anyhow. I’ll logged this as an issue in Core/Tor repo. Thanks again for your help.