WebSocket API: signature user data subscription is lost after reconnect
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- backend, networking
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 3k
- Fork
- 712
- Merge medio
- 1g 5h
- PR unite (30g)
- 4
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di binance/binance-connector-python
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
binance/binance-connector-python#570 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
binance/binance-connector-python#514 · 3 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 15/100
binance/binance-connector-python#575 · 1 commento ·
-
[Bug] Response models declare numeric fields as strict `str`, causing silent fallback of `.data()` to raw dict (simple-earn & staking)Forse già presa @Tyagiquamar l’ha presa 33 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
binance/binance-connector-python#553 · 2 commenti ·
Tutte le issue di binance/binance-connector-python
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
521xueweihan/HelloGitHub#4063 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Vanilla-OS/apx-gui#112 ·
-
Devstral and Voxtral: section 5 fails in us-east-1 with 400 "Model does not support audio modality"Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
aws-samples/sample-per-model-bedrock#409 ·
I maintainer di solito rispondono entro 1 giorno
-
DuckDB 2.0 breaks to_pyarrow_batchesForse già presa @DG47 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
ibis-project/ibis#12196 ·
I maintainer di solito rispondono entro 1 giorno