Skip to content

v2/server/rack: negotiate the WebSocket subprotocol (RFC 6455)#27

Merged
bradgessler merged 1 commit into
mainfrom
v2-rack-subprotocol
Jun 22, 2026
Merged

v2/server/rack: negotiate the WebSocket subprotocol (RFC 6455)#27
bradgessler merged 1 commit into
mainfrom
v2-rack-subprotocol

Conversation

@bradgessler

Copy link
Copy Markdown
Contributor

The v2 Rack opened the WebSocket without echoing a negotiated Sec-WebSocket-Protocol; the v1 handler always did (protocols: ['ws']). Edges/proxies like Fly drop a WS whose offered subprotocol the server never echoes — the client closes before hello. Echo the first mutually-supported subprotocol on both the async (Falcon) and threaded (Puma) paths. Gem specs 90/0.

The v2 Rack opened the WebSocket without echoing a negotiated Sec-WebSocket-Protocol
(async path passed no `protocols:`; the threaded path omitted the header). The v1
handler always negotiated (`protocols: ['ws']`). Some edges/proxies (Fly) drop a
WebSocket whose offered subprotocol the server never echoes — the client then closes
before sending hello ("client closed before hello"). Echo the first subprotocol both
sides support (terminalwire.v2, else ws) on both the async and threaded paths.
@bradgessler bradgessler merged commit d704e73 into main Jun 22, 2026
@bradgessler bradgessler deleted the v2-rack-subprotocol branch June 22, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant