Skip to content

feat(proxy): cherry-pick PR #666 proxy enhancements to v1.4#682

Merged
Issac-Newton merged 33 commits intoalibaba:release/v1.4from
xdlkc:release/v1.4
Mar 27, 2026
Merged

feat(proxy): cherry-pick PR #666 proxy enhancements to v1.4#682
Issac-Newton merged 33 commits intoalibaba:release/v1.4from
xdlkc:release/v1.4

Conversation

@xdlkc
Copy link
Copy Markdown
Contributor

@xdlkc xdlkc commented Mar 27, 2026

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

  • WebSocket proxy supports user-specified port via rock_target_port query param or X-ROCK-Target-Port header
  • HTTP proxy supports all HTTP methods
  • VNC proxy with fixed port 8006 forwarding (/sandboxes/{id}/vnc/{path})
  • WebSocket binary data handling fixes for VNC/noVNC
  • Location header rewrite for 3xx responses

refs #666

xdlkc added 30 commits March 27, 2026 19:51
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
xdlkc added 3 commits March 27, 2026 19:51
- 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}
@Issac-Newton Issac-Newton merged commit 7608b6d into alibaba:release/v1.4 Mar 27, 2026
4 checks passed
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.

3 participants