Connection, Subscription & Heartbeat

Connect to 6MM WebSocket streams, subscribe to topics, keep connections alive, and process message envelopes safely.
View as Markdown

Use WebSocket streams for market data and private user-state updates that must stay current without polling.

Connection URL

wss://6mm.com/ws

Private streams require authentication context such as a listenKey or access token as described in the private channel documentation.

Subscribe

1{ "id": "1772007814666", "op": "subscribe", "args": ["market.depth.BTCUSDT"] }

Successful subscription acknowledgement:

1{
2 "id": "1772007814666",
3 "event": "subscribe",
4 "success": true,
5 "data": ["market.depth.BTCUSDT"]
6}

Unsubscribe

1{ "id": "1772007814667", "op": "unsubscribe", "args": ["market.depth.BTCUSDT"] }

Application ping

1{ "id": "1772007814668", "op": "ping", "args": [] }

Message envelope

Public pushes use a consistent envelope:

1{
2 "topic": "market.depth.BTCUSDT",
3 "event": "data",
4 "ts": 1772007815000,
5 "data": {}
6}

Operational recommendations

  • Generate a unique client-side id for every subscribe, unsubscribe, and ping request.
  • Treat reconnect as a new session and resubscribe to required topics.
  • Validate that the returned topic matches the channel your service expects.
  • Keep message processing idempotent where private order or account events are involved.
  • Log connection state changes, subscription acknowledgements, and abnormal disconnects.