-
Notifications
You must be signed in to change notification settings - Fork 885
feat: automatically use websockets if DERP upgrade is unavailable #6381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This might be our biggest hangup for deployments at the moment... Load balancers by default do not support the DERP protocol, so many of our prospects and customers run into failing workspace connections. This automatically swaps to use WebSockets, and reports the reason to coderd. In a future contribution, a warning will appear by the agent if it was forced to use WebSockets instead of DERP.
7cc624e
to
589ead1
Compare
ad23191
to
44aa875
Compare
@mafredri I'm going to wait to merge this until you approve... I've brought too many race conditions into this code to risk introducing more 😅😅😅 |
Resolves #6375 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a few things stood out, but other than that this looks good, nice change!
// speak WebSockets (they still assumed DERP's binary framing). So to distinguish | ||
// clients that actually want WebSockets, look for an explicit "derp" subprotocol. | ||
if up != "websocket" || !strings.Contains(r.Header.Get("Sec-Websocket-Protocol"), "derp") { | ||
base.ServeHTTP(w, r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we log here to better understand why it may not be working? (E.g. future bugs.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so because this could be spammy.
91fbf09
to
b830fad
Compare
This might be our biggest hangup for deployments at the moment...
Load balancers do not support the DERP protocol by default (and many do not at all), so many of our prospects and customers run into failing workspace connections. After the first DERP connection HTTP response with a non
http.StatusSwitchingProtocols
response code (and <500), we will begin using WebSockets instead of DERP. It will never attempt to switch back for now.In a future contribution, a warning will appear by the agent if it was forced to use WebSockets instead of DERP.
Depends on coder/tailscale#8
Related #6372