feat(proxy): cherry-pick PR #666 proxy enhancements to v1.4#682
Merged
Issac-Newton merged 33 commits intoalibaba:release/v1.4from Mar 27, 2026
Merged
feat(proxy): cherry-pick PR #666 proxy enhancements to v1.4#682Issac-Newton merged 33 commits intoalibaba:release/v1.4from
Issac-Newton merged 33 commits intoalibaba:release/v1.4from
Conversation
…access" This reverts commit ddf9d13.
…tps redirect loop
…ep in message forwarding
receive_text() and receive_bytes() share the same ASGI message queue. When receive_text() consumed a binary frame and raised KeyError, the frame was permanently lost — the fallback receive_bytes() read the NEXT message instead. This silently dropped ~50% of binary frames, breaking VNC/noVNC and other binary WebSocket protocols. Switch to raw receive() which reads exactly once per message, then dispatches by content type. Also removes per-frame logger.info calls that printed full binary content (severe perf hit for VNC traffic) and fixes websockets v15+ compat (ConnectionClosed import path). Made-with: Cursor
- Remove HTTP routes: /sandboxes/{id}/proxy/port/{port}/{path}
- Remove WS routes: /sandboxes/{id}/proxy/port/{port}/ws/{path}
- Add generic WS route: /sandboxes/{id}/proxy/{path}
- Port now only specified via rock_target_port query parameter
- Update tests to verify new behavior
- Add HTTP routes: /sandboxes/{sandbox_id}/proxy/vnc/{path}
- Add WebSocket route: /sandboxes/{sandbox_id}/proxy/vnc/{path}
- Fixed port forwarding to 8006 for all VNC requests
- Ignore rock_target_port query parameter for VNC routes
- Add comprehensive unit tests for HTTP and WebSocket VNC proxy
- Add spec, plan, and task documentation to docs/_specs/vnc-proxy/
- Add X-ROCK-Target-Port header support for HTTP proxy - Add X-ROCK-Target-Port header support for WebSocket proxy - Return 400 error when both header and query param are specified - Add resolve_target_port helper function - Add comprehensive tests for header port support
- Document X-ROCK-Target-Port header for WebSocket proxy - Document X-ROCK-Target-Port header for HTTP proxy - Add usage examples with header - Document conflict error when both header and query param are specified
- Restore /sandboxes/{sandbox_id}/proxy/port/{port}/{path} routes (backward compatible)
- Restore /sandboxes/{id}/proxy/port/{port}/ws/{path} WebSocket routes
- Fix VNC proxy: add proxy_prefix and query_string parameters
- This fixes Location header rewriting for noVNC callbacks
- Add resolve_target_port_from_ws for WebSocket port resolution - Both HTTP and WebSocket proxy extract port from path (port/8006/...) - Return 400 error when port specified via multiple sources - Update tests to reflect new behavior
FastAPI matches routes by registration order. VNC WebSocket route must be
registered before generic /proxy/{path:path} to match correctly.
Shorter URL path for VNC access:
- HTTP: /sandboxes/{id}/vnc/{path}
- WebSocket: /sandboxes/{id}/vnc/{path}
StephenRi
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cherry-pick PR #666 (feat(proxy): websocket proxy support user-specified port; http proxy support all methods) to release/v1.4 branch.
Key Features
rock_target_portquery param orX-ROCK-Target-Portheader/sandboxes/{id}/vnc/{path})refs #666