getlantern / browsersunbounded

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

Unexplained WebSocket frame errors #114

Closed noahlevenson closed 1 year ago

noahlevenson commented 1 year ago

Tonight, I ran a little experiment just to assure myself that our N:M multiplexing still works:

  1. I spun up a single uncensored peer using ./widget

  2. I spun up 3 censored peers using ./derek.sh 3

  3. The 3 censored peers all established connections through the single widget

  4. I made sure that each censored peer could round trip requests by hitting curl --proxy http://127.0.0.1:108n https://www.nytimes.com for n = [1, 3]

The test passed and everything worked great. I left the widget and the censored peers running while I attended to other tasks. When I came back, I saw that the widget had mysteriously experienced WebSocket errors:

2023/03/01 20:12:38 websocket: failed to marshal close frame: reason string max is 123 but got "failed to get reader: failed to read frame header: read tcp [2600:4041:5b12:5e00:26c4:8a40:5a68:1a37]:36708->[2001:4860:4802:34::35]:443: read: connection reset by peer" with length 168
2023/03/01 20:12:38 Egress consumer WebSocket read error: failed to get reader: failed to read frame header: read tcp [2600:4041:5b12:5e00:26c4:8a40:5a68:1a37]:36708->[2001:4860:4802:34::35]:443: read: connection reset by peer
2023/03/01 20:12:38 Egress consumer state 0, opening WebSocket connection...
2023/03/01 20:12:38 Egress consumer state 1, WebSocket connection established!
2023/03/01 20:16:36 websocket: failed to marshal close frame: reason string max is 123 but got "failed to get reader: failed to read frame header: read tcp [2600:4041:5b12:5e00:26c4:8a40:5a68:1a37]:39538->[2001:4860:4802:34::35]:443: read: connection reset by peer" with length 168
2023/03/01 20:16:36 Egress consumer WebSocket read error: failed to get reader: failed to read frame header: read tcp [2600:4041:5b12:5e00:26c4:8a40:5a68:1a37]:39538->[2001:4860:4802:34::35]:443: read: connection reset by peer
2023/03/01 20:16:36 Egress consumer state 0, opening WebSocket connection...
2023/03/01 20:16:36 Egress consumer state 1, WebSocket connection established!

The widget did what it's supposed to do -- it detected the dead WebSocket and dialed up a new WebSocket connection. But what's going on and why?

noahlevenson commented 1 year ago

I'm pretty sure I see this -- or something like it -- happening regularly, particularly now that the services are deployed on Heroku.

Are middleboxes closing our extensions' idle websocket connections?

noahlevenson commented 1 year ago

I haven't seen this since we added a keepalive, so I'm closing it for now...