Skip to content

Binance USD-M WebSocket streams send nothing on the legacy fstream paths, so live prices and perp candles always fall back to REST #420

Done

Description

@harbourlark

Describe the bug

Binance split the USD-M futures WebSocket host into /public, /market and /private paths (notice, legacy URLs retired on 23 April 2026). On the old root paths, market streams such as markPrice, kline, aggTrade and ticker now connect fine but never send a message. Depth and bookTicker still work on the old path for now.

Two places in QuantDinger still build the old URLs for Binance swap:

  1. Backend, backend_api_python/app/services/market_price_stream.py (_url, around line 241):

    host = "wss://fstream.binance.com" if swap else "wss://stream.binance.com:9443"
    return f"${host}/stream?streams=${streams}"   # ...@markPrice@1s

    The socket opens, _connected goes true, but no mark price ever arrives, so every Binance swap snapshot comes from rest_fallback.

  2. Frontend (QuantDinger-Vue), src/utils/exchangeWs.js, Binance buildUrl:

    ? 'wss://fstream.binance.com/ws'   // ...@kline_<interval>

    The chart waits 12 s, logs "connected but no data received" and switches to REST polling for Binance perps.

The fix is the path only. Message shapes are unchanged (combined { stream, data } on /market/stream, raw kline events on /market/ws), so the parsers can stay as they are:

host = "wss://fstream.binance.com/market" if swap else "wss://stream.binance.com:9443"
? 'wss://fstream.binance.com/market/ws'

The order book in exchangeOrderBookWs.js (@depth20@100ms on /ws) still streams today; its new home is wss://fstream.binance.com/public/ws if you want to move it at the same time. The unit tests that assert the old swap URLs would need the same one-line change.

The same notice moves listenKey user-data streams to /private, which would cover wss://fstream.binance.com/ws/{listenKey} in execution_streams/adapters.py. I could not test that one without an API key, so treat it as something to check rather than a confirmed bug.

I help maintain the Siebly Binance SDK for Node.js, which moved to these paths, and that is how I noticed. Happy to open a PR on either repo if that helps.

Steps to reproduce

Node 22 or later (global WebSocket), counting messages per URL for 15 seconds:

const urls = [
  'wss://fstream.binance.com/stream?streams=btcusdt@markPrice@1s/ethusdt@markPrice@1s',
  'wss://fstream.binance.com/market/stream?streams=btcusdt@markPrice@1s/ethusdt@markPrice@1s',
  'wss://fstream.binance.com/ws/btcusdt@kline_1m',
  'wss://fstream.binance.com/market/ws/btcusdt@kline_1m',
  'wss://fstream.binance.com/ws/btcusdt@depth20@100ms',
  'wss://fstream.binance.com/public/ws/btcusdt@depth20@100ms',
];
const count = (url) => new Promise((resolve) => {
  let n = 0;
  const ws = new WebSocket(url);
  ws.onmessage = () => n++;
  setTimeout(() => { ws.close(); resolve(`${String(n).padStart(4)}  ${url}`); }, 15000);
});
for (const line of await Promise.all(urls.map(count))) console.log(line);

In the app: open a Binance perpetual chart (for example BTC/USDT swap) with realtime on and watch the browser console, or start a Binance swap strategy and check the price feed snapshot source.

Expected behavior

Binance swap mark prices and candles arrive over the WebSocket (source = public_websocket), with REST only as the fallback.

Deployment method

Other

Relevant logs

2026-11-28T03:40:56Z (Node 24.22.1)
   0  wss://fstream.binance.com/stream?streams=btcusdt@markPrice@1s/ethusdt@markPrice@1s
  28  wss://fstream.binance.com/market/stream?streams=btcusdt@markPrice@1s/ethusdt@markPrice@1s
   0  wss://fstream.binance.com/ws/btcusdt@kline_1m
  14  wss://fstream.binance.com/market/ws/btcusdt@kline_1m
 124  wss://fstream.binance.com/ws/btcusdt@depth20@100ms
 124  wss://fstream.binance.com/public/ws/btcusdt@depth20@100ms

Activity

  1. added
    bug
    on Nov 28, 2026
  2. harbourlark commented on Nov 28, 2026

    @harbourlark
    Author

    Thanks for the quick fix. I ran the merged routes against the live endpoints for 10 s each: btcusdt@markPrice@1s on /market/stream gave 9 messages, kline_1m on /market/ws 17 and depth5@100ms on /public/ws 82, while the old root /stream stayed at 0. All good from here.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions