remote: pair --remote tunnel fails to serve /api/session on Windows

未关闭
#66,981 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript

调研方向

Start with opencode pair --remote --yes, compare local and tunnel responses for /api/info and /api/session, and inspect the built-in OpenTunnel client/relay path plus Windows CLI packaging. Use the tunnel request logs and ~/.local/share/opencode/log/opencode.log to identify where TLS handshaking or response streaming stalls. Done means both authenticated endpoints remain reliably reachable through the Windows tunnel, including the larger session response.

由索引模型根据 Issue 内容生成。

描述

area/service platform/windows type/bug version/v2
Description

Summary

opencode pair --remote produces an OpenTunnel URL that is not usable from Windows: the tunnel host accepts TCP but TLS/HTTP requests intermittently fail with handshake errors or hang. /api/info sometimes returns 200, while /api/session consistently times out, so the mobile app cannot load sessions. The local service is healthy, so this looks like a problem with the built-in OpenTunnel relay/client, not with session storage.

Environment

  • opencode version: 2.1.4 (CLI bundled with OpenCode Desktop). A separate 2.4.2 CLI is installed, but the Desktop app automatically keeps the background service on 2.1.4.
  • OS: Windows 10 Pro, 10.0.19045.6456 (win32 x64).
  • Terminal: TERM=xterm-256color; TERM_PROGRAM, COLORTERM, WT_SESSION, ConEmuPID not set.
  • Shell: ComSpec=C:\Windows\system32\cmd.exe (commands executed from PowerShell 5.1).
  • Install/channel: desktop bundle, channel latest.
  • Active plugins: none found in ~/.config/opencode/opencode.json, ~/.config/opencode/opencode.jsonc, workspace opencode.json / opencode.jsonc, or .opencode/plugin(s) directories.

Reproduction

  1. Start/confirm the background service: opencode service status → http://127.0.0.1:28894.
  2. Run opencode pair --remote --yes.
  3. The command prints a one-time URL like https://<random>.e2j5z6dq6j6t.opentunnel.xyz/auth/connect/<token>.
  4. From the same PC, request API endpoints through the tunnel with the service Basic auth:
    • curl -u "opencode:<password>" https://<tunnel-host>/api/info
    • curl -u "opencode:<password>" https://<tunnel-host>/api/session
  5. Compare with the same endpoints on http://127.0.0.1:28894.

Expected Behavior

The remote URL should proxy all authenticated API endpoints reliably, including /api/session, so a browser or mobile app can load the session list.

Actual Behavior

Local endpoints are fast and correct:

/api/info    -> HTTP 200
/api/session -> HTTP 200, 34839 bytes, ~0.10 s

Through the tunnel, across three generated links and two tunnel hostnames:

/api/info    -> HTTP 200 1.66 s, then later:
                 curl: (35) schannel: failed to receive handshake, SSL/TLS connection failed
/api/session -> curl: (28) Connection timed out after 25006 milliseconds 000 25.006943
/api/session?limit=1, /api/session?limit=5, /api/project -> TLS handshake failures

An independent external fetch of the same https://<tunnel-host>/api/info also timed out, so the failure is not specific to this PC/network. DNS resolves the tunnel host to 168.220.93.252; a raw TCP connect to port 443 succeeds, but the TLS handshake fails. Sometimes Get-NetTCPConnection showed established connections to the relay, but requests still hung.

The mobile app reports "не удалось загрузить сессии" ("failed to load sessions") after a successful pairing, which matches /api/session failing through the tunnel.

Additional Context

  • Frequency: consistently reproducible over several hours; /api/info is intermittently reachable, /api/session is not.
  • Full toggle did not help: service set remote false → service restart → service set remote true → service restart → pair --remote --yes produced a new hostname with the same behavior.
  • opencode service get remote returns true; opencode service get cors returns []; local /api/info lists both http://127.0.0.1:28894 and the tunnel URL.
  • No tunnel-specific errors were found in ~/.local/share/opencode/log/opencode.log at the default log level. pair --remote --yes --print-logs --log-level debug produced no extra diagnostics; the CLI help notes server logs require --standalone.
  • Attempting to use a standalone OpenTunnel CLI on Windows is not currently possible: npm install -g opentunnel installs only the wrapper, opentunnel route add 28894 says the right platform CLI is missing, and @opentunnel/cli-win32-x64 returns 404.
  • Switching the background service to the separately installed 2.4.2 CLI does not stick because OpenCode Desktop restarts the 2.1.4 service.
  • Workaround that works: reverse SSH tunnel from the PC to a trusted VPS, plus a Caddy HTTPS reverse proxy on a public hostname. Both /api/info and /api/session then return 200 in about 0.5 s, and the mobile app connects.
  • Please check the Windows built-in OpenTunnel client/relay path, especially TLS handshake and larger/longer API responses such as /api/session.
Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot

No response

Operating System

No response

Terminal

No response

主要语言
TypeScript
星标
230k
派生
31.3k
平均合并
5 小时 32 分钟
30 天内合并 PR
453

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。