mirror of
https://github.com/agrinman/tunnelto.git
synced 2026-04-26 01:06:01 +03:00
[GH-ISSUE #41] Gracefully handle websocket Close messages #37
Labels
No labels
Need more info
bug
duplicate
enhancement
good first issue
good first issue
help wanted
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tunnelto#37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jeromegn on GitHub (Mar 29, 2021).
Original GitHub issue: https://github.com/agrinman/tunnelto/issues/41
Maybe I missed it, but I don't think tunnelto gracefully handles websocket close messages and/or reconnects.
Testing this locally with a proxy (Fly.io) in-between tunnelto clients and servers: if the proxy goes away, the tunnel client appears to reconnect, but not without an error and then every request to the tunnel endpoint (
<sub>.tunnelto.dev) will fail. Your users will have to manually start/stop their tunnel.The client shows the following:
and then trying to make a request:
I'm assuming this happens because a new subdomain is generated for the tunnel, but it's not printed.
Fly's proxy sends a "Restart" close message, to both the client and server, when we deploy. Normal websocket operations dictates clients and servers should try reconnecting when that happens. With
tunstenite, that's a matter of handling theMessage::Close(Option<CloseFrame>)appropriately depending on the close reason.I would suggest the same hostname should be kept around on reconnect. The client should have rights to use the same hostname it was previously using for a reconnect sequence.
Restarting of our proxy is a normal part of operation. It does offer zero-downtime, but not for websocket connections (or other very long lives connections). It does the next best thing by gracefully closing the connections, expecting the clients to reconnect (on the freshly deployed version of our proxy).
@agrinman commented on GitHub (Apr 3, 2021):
Ah thanks so much for this explanation @jeromegn! This is definitely why the tunnel occasionally breaks and needs restarting. I don't believe I am handling the close message correctly. I will address this shortly -- thanks again!
@agrinman commented on GitHub (Apr 3, 2021):
Ah so this issue occurs when you are using an anonymous tunnel only (if you're authenticated + specify a subdomain it will persist the tunnel of course)
@agrinman commented on GitHub (Apr 18, 2021):
This should be fixed now 0.1.14!