Skip to content

Use Binance MessageRouter subscribe payload instead of WsMessage::Subscribe #40

Closed

Description

@daniil4udo
  • BinanceWs currently calls WsClient::subscribe(...) (defined in ccxt-core/src/ws_client/mod.rs), which serializes the generic WsMessage::Subscribe enum as
{ "type": "subscribe", "channel": ..., "symbol": ..., "params": ... }

. That payload is incorrect for Binance: the exchange expects

{ "method": "SUBSCRIBE", "params": ["btcusdt@fundingRate"], "id": 12345 }

(and similar for unsubscribe).

  • The repository already contains a correct implementation in ccxt-exchanges/src/binance/ws/handlers.rs::MessageRouter::subscribe(), which builds the Binance-specific JSON and calls client.send(...) directly. However, nothing uses MessageRouter — BinanceWs still goes through WsClient::subscribe, so the Binance-specific format is never actually sent.
  • Because of that, Binance rejects important streams such as funding rate updates and other symbol-specific streams, and existing integration tests (e.g., ccxt-exchanges/tests/binance_ws_subscribe_payload_test.rs) need the true Binance payload.

Suggested fix

Wire BinanceWs to create/connect a MessageRouter (or otherwise use the same serde_json::json!({ "method": "SUBSCRIBE", "params": streams, "id": ... }) payload) for every subscribe/unsubscribe path so that the correct Binance-format JSON goes over the wire. Keeping or expanding the existing payload test will prevent regressions once the router is used.

Activity

  1. Praying commented on Jan 25, 2026

    @Praying
    Owner

    @daniil4udo Thank you for your feedback. I've made some adjustments based on your comments. If you have time, I'd like to review them with you. PR42

  2. daniil4udo commented on Jan 26, 2026

    @daniil4udo
    Author

    That was very fast @Praying ! Lets see what you've got

  3. Praying commented on Jan 30, 2026

    @Praying
    Owner

    @daniil4udo I've released v0.1.4 of ccxt-rust, I think it should have fixed the issue you raised, try it if you have time https://crates.io/crates/ccxt-rust

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions