[Bug]: Relay socket dropped with code 1006 every few minutes while idle — no keepalive, no close reason logged

未關閉
#207 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
web-dev
領域
networking

研究方向

Start by locating the relay-client WebSocket implementation and its close and reconnect handling; the issue does not name source files or tests. Check how the socket is kept alive and what close details are available, then trace how a relay disconnect affects connected clients. Done means idle connections stay registered, close details are diagnosable, and clients recover from a dropped link.

由索引模型根據 Issue 內容生成。

描述

Platform

Linux

Operating system version

Debian 13 (standalone server, polyscope-server 0.29.0 running as a systemd unit)

System architecture

Intel (x86_64)

PolyScope Version

0.29.0

Bug description

The relay socket to relay-edge.getpolyscope.com is closed with code 1006 ("Connection ended") on a regular cycle, and it does this when the server is completely idle — no remote client attached, no agent running, nothing hitting the API.

From our log over ~3 days on one server:

[relay-client] Disconnected from relay (code: 1006, reason: Connection ended)
[relay-client] Reconnecting in 5s...
[relay-client] Connecting to relay at wss://relay-edge.getpolyscope.com...
[relay-client] Connected to relay
[relay-client] Registered as server <id>
  • 589 such drops in the log
  • 539 of 589 (91%) have no client request or diff work in the 40 log lines before them — i.e. the link was idle
  • Average interval while idle: ~7 minutes (a separate stretch measured 119 drops over 3.8 days ≈ 45 min; the rate degrades over uptime)

The server itself is healthy the whole time: ~1.4% CPU, 105 MB RSS, no errors, no restarts, network path to the relay fine (TLS handshake and Registered as server succeed within ~4 s every time).

Two things I can see from the client side of this binary:

  1. There is no application-level keepalive. Searching the compiled relay-client code, there's no setInterval, no ping/pong, no heartbeat around the relay socket — only Reconnecting in Ns backoff after a close. If the edge is reaping idle WebSockets, nothing on the server is holding it open.
  2. The close reason is never logged. We get code: 1006, reason: Connection ended and nothing else — no close frame from the edge, no distinguishing between idle timeout, edge restart and network death. 1006 means "no close frame received", so it's being cut underneath the client.

Impact: every drop kills the E2E session for whatever tabs are open. The tab shows a hung/blank page and only recovers on a manual reload — some of the time not even then. Users see "Polyscope has frozen" while the server is perfectly fine.

Steps to reproduce
  1. Run polyscope-server standalone, signed in, relay connected.
  2. Attach no remote clients and leave it completely idle.
  3. Watch the log: Disconnected from relay (code: 1006, reason: Connection ended) arrives within minutes, then reconnects, then repeats indefinitely.
  4. Alternatively watch the socket: ss -tinp | grep 443 | grep polyscope — the source port rotates and lastsnd/lastrcv go stale before each close.
Expected
  • The relay client should send a WebSocket ping (or equivalent keepalive) at an interval shorter than the edge's idle timeout, so an idle server stays registered.
  • Log the actual close code and any close-frame reason from the edge, so this is diagnosable from the server side without guessing.
  • Connected clients should be told the link dropped (and re-establish) rather than showing a hung page.
Relevant log output
[relay-client] Connecting to relay at wss://relay-edge.getpolyscope.com...
[relay-client] Connected to relay
[relay-client] Registered as server <id>
[relay-client] Remote client connected: <uuid> (1 remote)
[relay-client] E2E established with client <uuid>
[relay-client] Remote client disconnected: <uuid> (0 remote)
[relay-client] Disconnected from relay (code: 1006, reason: Connection ended)    <-- no client activity, link idle
[relay-client] Reconnecting in 5s...
[relay-client] Connecting to relay at wss://relay-edge.getpolyscope.com...
[relay-client] Connected to relay
[relay-client] Registered as server <id>
主要語言
沒有語言資料
星號
20
分支
0
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

beyondcode/polyscope-community 的其他 Issue

查看 beyondcode/polyscope-community 的全部 Issue

相似的 Issue

更多 Networking Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。