A couple of questions about websocket limits

Hi there

Is it allowed to create multiple websocket connections to subscribe to over 1024 streams from a single IP/Machine ? Let’s say three connections with 500 stream subscriptions each, so 1500 in total.

In the docs it says there is a limit of 5 incoming messages per second, but it does not clarify if the limit is for a single connection or multiple connections from a single IP/Machine combined. Let’s say we still have the three connections, does it mean that the websocket server allows 5 messages a second per individual connection (15 in total) or 5 messages per all connections combined (5 in total) ?

Thank you

Futures has similar websocket limits, this is for spot:

  • One IP can build unlimited Websocket connections.
  • One connection can subscribe up to 1024 streams.
  • One IP can send 5 messages per second, message include:
    • Connection
    • Disconnection
    • Subscription
    • Unsubscription
    • Ping
    • Pong
    • etc

@dino what will happens if I send more then 5 messages per second?

If limit is violated, there will be disconnection and if if the IP is repeatedly disconnected, then it may be banned.

Do binance send any warning massages? How Do I know if disconnection happen because of limit violations.

the connection will be disconnected

Still not clear. For example my server use 1000 separate connections from same IP address. And at given moment very likely more then 5 ping msgs will send at same time. Will it terminate all connections or some and how I should handle it? Do you send some terminate signals and what code?

I think “incoming messages” means messages that the user sends to Binance. @dino is this correct?

The 5 incoming messages per second rate limit applies to each individual connection independently. If all your connections send pings at the same time, that should be fine as long as each individual connection sends pings at a reasonable rate.

If the rate limit is violated, your connection will be terminated. You’ll get a close frame with the standard Policy Violation status code (1008), and the close frame body will be “Too many requests”.

1 Like