WebSocket API: signature user data subscription is lost after reconnect
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
- 领域
- backend, networking
调研方向
Start with common/src/binance_common/websocket.py and reconnect() around line 916, then follow how userDataStream.subscribe.signature stores subscription state and how callbacks are keyed by subscriptionId. Reproduce with the described local aiohttp WebSocket server and the failing pytest mentioned in the issue. Done means signature subscriptions are restored after reconnect, callbacks use the new subscription ID, and resubscribe failures emit an error.
由索引模型根据 Issue 内容生成。
描述
Summary
A user data subscription made with userDataStream.subscribe.signature (no session.logon) is not restored when the WebSocket API connection reconnects, including the planned reconnect before the 24h limit and after serverShutdown. The bot stops receiving execution reports and balance updates, and no event or error is raised.
Where
common/src/binance_common/websocket.py, reconnect() (line 916 at a54ec0b): user streams are only resubscribed inside if connection.session_logon_request and self.configuration.session_re_logon. A signature subscription stores no logon request, so nothing is sent on the new connection, and user_stream_connections still points to the closed one.
Reproduction
Local aiohttp WebSocket server, no Binance network:
userDataStream.subscribe.signatureon a WS API client in single mode; the server replies withsubscriptionId: 0.- The server sends
serverShutdown(or the reconnect timer fires). - The client opens connection 2, but the server receives no subscribe request on it, and events pushed there never reach the callback.
I have this as a failing pytest and can share it.
Suggested fix
- Store the subscribe request per subscription, as
session_logon_requestis stored, and replay it, re-signed with a fresh timestamp, after reconnect. - Remap the callbacks to the
subscriptionIdreturned on the new connection instead of assuming it is unchanged._resubscribe_user_streamson the logon path assumes the same id and does not await the reply. - If the resubscribe fails, emit an
errorevent so the application can react.
I'm happy to open a PR along these lines if this approach works for you.
Related, found while testing (each has a failing test, I can open separate issues or PRs)
- A reply that arrives after
asyncio.wait_for(future, 20)timed out raisesInvalidStateErrorinreceive_loop(future.set_resulton a cancelled future), which ends the loop: the connection stays open but nothing else is received. Fix: skip futures that aredone()and pop the id on timeout. - In pool mode,
subscribe_user_dataregisters the callback on the next connection in the round robin, not the one that sent the subscribe, so events are dropped. send_requestretries signedDELETE(order cancel) after aReadTimeout; the first request was already delivered, so the retry returns-2011 Unknown order sent.for an order that was cancelled. Retrying only on connect errors and 5xx would avoid it.
- 主要语言
- Python
- 星标
- 3k
- 派生
- 712
- 平均合并
- 1 天 5 小时
- 30 天内合并 PR
- 4
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
binance/binance-connector-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 88/100
binance/binance-connector-python#570 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
binance/binance-connector-python#514 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 15/100
binance/binance-connector-python#575 · 1 条评论 ·
-
[Bug] Response models declare numeric fields as strict `str`, causing silent fallback of `.data()` to raw dict (simple-earn & staking)可能已有人在做 @Tyagiquamar 于 32 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 68/100
binance/binance-connector-python#553 · 2 条评论 ·
查看 binance/binance-connector-python 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
anchore/grype-db#1149 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug]: `hermes plugins update` clones an entire monorepo twice - `subdir` is resolved but dropped at both catalog-update call sites可能已有人在做 @HootRock 今天认领。 未关闭comp/cli P2 type/perf
难度 2/5 1-3 小时 新手友好度 72/100
NousResearch/hermes-agent#142417 · 2 条评论 ·
维护者通常 1 天内回复
-
SMC SPEC
难度 2/5 1-3 小时 新手友好度 70/100
tenstorrent/tt-oca-harness#3287 ·
维护者通常 1 天内回复
-
bug enhancement python
难度 2/5 1-3 小时 新手友好度 85/100
DewaldOosthuizen/tech-cheat-sheets-and-notes#392 ·
维护者通常 1 天内回复
-
security
难度 2/5 1-3 小时 新手友好度 72/100
fabriziosalmi/wildbox#801 ·
维护者通常 1 天内回复