Websocket incoming message rate limit

Hi,
I encounter unexpected behavior when sending message, from the documentation :

  • WebSocket connections have a limit of 5 incoming messages per second. A message is considered:
    • A PING frame
    • A PONG frame
    • A JSON controlled message (e.g. subscribe, unsubscribe)

So I suppose we have to wait a minimum of 1000ms/5 between each messages to send, may be a slight more, like 210ms to be sure to never reach the limit rate.

I’m testing with 4 message per seconds basis, so I’m sending message with at least 250ms delay between them but got rejected :


17:01:08.247 INFO  WebSocketStream sent message {"method":"SET_PROPERTY","id":"settings","params":["combined",false]}
17:01:08.549 INFO  WebSocketStream sent message {"method":"SUBSCRIBE","id":"btcusdt","params":["btcusdt@kline_1m"]}
17:01:08.813 INFO  WebSocketStream sent message {"method":"SUBSCRIBE","id":"ethusdt","params":["ethusdt@kline_1m"]}
17:01:09.077 INFO  WebSocketStream sent message {"method":"SUBSCRIBE","id":"dotusdt","params":["dotusdt@kline_1m"]}
17:01:09.341 INFO  WebSocketStream sent message {"method":"SUBSCRIBE","id":"xrpusdt","params":["xrpusdt@kline_1m"]}
17:01:09.604 INFO  WebSocketStream sent message {"method":"SUBSCRIBE","id":"woousdt","params":["woousdt@kline_1m"]}
17:01:10.324 INFO  [OkHttp https://stream.binance.com:9443/...] INFO  CLOSING event 1008 Too many requests

Either on testnet or mainnet.
The first message I send is not stated in the doc, but it does not seems to change something. (and the others are sent in one single multi subscribe normally, this is for the test here).
From my experimentation, I’ve found that I should wait at least 366ms between each message sending to not get rejected, which is less than 3 message / seconds. At 3 message / seconds, sometime it works, sometime not.

So, I’m wondering if those limit are up to date ?
Or if I should retrieve them from the exchange info end point ?
Or if it’s good on your side and it’s my clock or my code that go wrong ?

Thanks !

It doesn’t have to be one msg per 200ms (1000ms/5), as long as you respect the max 5 msg within 1 sec, it’s fine. Ex: You can send 5 msgs in the first 200ms.

Now the 1008 is due to "Spot server is currently overloaded with other requests. " (from binance-spot-api-docs/errors.md at master · binance/binance-spot-api-docs · GitHub)