Skip to content

fix(server): proxy websocket sandbox routes#388

Open
liuxiaopai-ai wants to merge 1 commit intoalibaba:mainfrom
liuxiaopai-ai:codex/issue-383-server-ws-proxy
Open

fix(server): proxy websocket sandbox routes#388
liuxiaopai-ai wants to merge 1 commit intoalibaba:mainfrom
liuxiaopai-ai:codex/issue-383-server-ws-proxy

Conversation

@liuxiaopai-ai
Copy link
Contributor

Summary

  • add server-side websocket proxy routes for /sandboxes/{id}/proxy/{port} and nested paths
  • support proxying the root path returned by use_server_proxy=true
  • forward endpoint routing headers through both HTTP and websocket proxy paths

Root cause

Issue #383 is real. The server proxy only registered HTTP routes and explicitly treated websocket upgrades as unsupported, so browser websocket handshakes never reached the sandbox backend. Separately, get_endpoint(..., use_server_proxy=true) returned /proxy/{port} but the server only handled /proxy/{port}/{full_path}.

Testing

  • cd server && uv run pytest tests/test_routes_proxy.py
  • cd server && uv run pytest tests/test_routes*.py
  • cd server && uv run pyright src/api/lifecycle.py tests/test_routes_proxy.py
  • cd server && uv run ruff check src/api/lifecycle.py tests/test_routes_proxy.py

Fixes #383

@liuxiaopai-ai
Copy link
Contributor Author

@ninan-nn @Pangjiping This should fix issue #383. Could you please take a look when you have a moment? Thanks!

@Pangjiping
Copy link
Collaborator

@ninan-nn @Pangjiping This should fix issue #383. Could you please take a look when you have a moment? Thanks!

Thanks for this, I will review this feature.

@Pangjiping Pangjiping added feature New feature or request component/server labels Mar 9, 2026
@hittyt
Copy link
Collaborator

hittyt commented Mar 15, 2026

@codex review

@hittyt
Copy link
Collaborator

hittyt commented Mar 15, 2026

@liuxiaopai-ai This PR has merge conflicts with the base branch.
Could you please resolve them so we can proceed with the review?

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13aeb2ca65

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

port,
exc,
)
await websocket.close(code=status.WS_1008_POLICY_VIOLATION)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Accept websocket before closing on backend handshake failure

This error path calls websocket.close() before any websocket.accept(), which in FastAPI/Starlette results in an HTTP denial response instead of a WebSocket close frame, so clients won't actually receive the intended close code (1008 here) and will observe a generic handshake failure instead. That makes backend handshake/connect failures indistinguishable and can break client logic that depends on WebSocket close semantics.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/server feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: 使用沙盒server部署openclaw,并且客户端跨服务器创建ui正常访问但是websocket403

3 participants