getlantern / browsersunbounded

Interoperable browser-based P2P proxies for censorship circumvention
GNU General Public License v3.0
11 stars 0 forks source link

Understand what happens when computers go to sleep #128

Closed noahlevenson closed 1 year ago

noahlevenson commented 1 year ago

I hypothesize that web clients start doing strange things when computers go to sleep.

We observed a situation where @Derekf5 left a web widget (not the extension!) running on his office computer, in Chrome, after he left the office. He surmised that his computer had almost definitely gone to sleep.

This coincided with strange connection counts being reported in Honeycomb: 11 WebSockets, and 6 signaling messages.

We know that given our current concurrency settings, WebSockets should be multiples of 10 and signaling messages should be multiples of 5.

As an experiment, I killed and restarted both of our services, just to see what any connected widgets would do. They immediately created the same 6 signaling messages. But they created 10 WebSockets, disconnected them, and then created 9 WebSockets. Very strange.

To be clear, our servers are designed to tolerate any odd number of connections, and so rogue clients behaving incorrectly aren't a risk to the network. But I've never been able to reproduce these kinds of connection counts, and I wonder if it's just because I don't have a Mac that can go to sleep?

It would be gratifying to understand the source of these weird connection count values when we see them in Honeycomb. We should run an experiment with some of our Mac users.

noahlevenson commented 1 year ago

Hypothesis confirmed: web clients do strange and wildly unpredictable things when computers to go to sleep. Most of the wacky things we've observed are indeed likely related to sleepy computers.

The TLDR: You can't count on any of the mathematical relationships you observe in Honeycomb to be meaningful. There can be odd numbers of open WebSockets, strange multiples of open signaling messages, lots of open WebSockets and no signaling messages (even in the absence of censored peers)... when it's sleepy time, all bets are off.

There doesn't seem to be any meaningful way to reason about churn, because we'll always have computers connecting and disconnecting in unpredictable ways while they're asleep.

It's worth considering what havoc may be wreaked by computers sending signaling messages while they're asleep. At scale, this would be very destructive.

@woodybury and I did a testing session wherein I monitored the logs while he ran a widget on his MacBook in Chrome, putting the computer to sleep under different circumstances. Some things we saw:

myleshorton commented 1 year ago

This is super interesting. We've had similar worries about core lantern in this state in the past. This area popped up in particular for basically marking proxies as blocked based on connections dying when devices are actually just sleeping. In fact, this is still a leading theory for why our blocking detection frequently thinks that servers in completely uncensored regions are blocked, at which point it dutifully replaces them.

On that side, this is a good example of where using our new bypass blocking detection approach is attractive.

woodybury commented 1 year ago

One of the coolest takeaways was the as long as there's an active webrtc connection (doesn't even need to be sending/receiving) chrome will keep the tab alive. Similar to the old hack of secretly playing blank audio to keep a tab alive.