ricochet icon indicating copy to clipboard operation
ricochet copied to clipboard

If Tor is offline long enough to stop building circuits, Ricochet will never recover

Open armadev opened this issue 8 years ago • 3 comments

Run ricochet, have it bootstrap Tor just fine. Then go offline for a while, then close your laptop for a while. When it comes back, if you've waited long enough, Tor will no longer have any "predicted ports", meaning any_predicted_circuits() returns 0, meaning Tor will fetch new consensuses, but it has stopped building preemptive circuits. Tor will remain in this sleepy position until a new socks request arrives, at which point it will wake up and start building preemptive circuits again.

This is all fine and good, except apparently Ricochet is waiting for Tor to emit the "I've built a circuit!" event. So both sides patiently wait for each other, and the result is that Ricochet gets stuck in the "Connecting..." state.

I don't yet know if this is a Ricochet bug or a Tor bug, i.e. whether we should aim to fix this on the Tor side or the Ricochet side. What exactly does Ricochet wait for?

armadev avatar Aug 07 '15 06:08 armadev

Ricochet won't attempt any new connections after a CIRCUIT_NOT_ESTABLISHED event, until the CIRCUIT_ESTABLISHED event arrives. The intent here is that we don't want to pretend contacts are offline and increase the connection attempt interval if there is no chance of the connection succeeding.

Regardless of whether it's a Tor bug, it sounds like we need a workaround or fix on the Ricochet side.

special avatar Aug 07 '15 06:08 special

What would happen if you do a 'getinfo dormant' after the circuit-not-established? And then if indeed Tor has gone dormant, you'll have to wiggle something so it wakes up. (But you don't have to let the user know that you wiggled anything.)

armadev avatar Aug 07 '15 06:08 armadev

I think we'd still have a problem, because tor could go dormant at some point after the circuit_not_established event. We could periodically ask tor if it's dormant, but we might not notice the connection being resumed for up to that interval.

It sounds like Ricochet should prevent tor from going dormant while circuits-established is false. It looks like making a connection every PredictedPortsRelevanceTime and after CLOCK_JUMPED, while circuits-established is false, would be enough.

special avatar Aug 13 '15 13:08 special