Data just 'stops' using websockets API for Spot market.

I have a python application which connects to the Binance Spot Market Websockets API. (using the libarary). I subscribe to 38 symbols for both trades and order_book updates using the websocket I/F.

Everything works fine for some amount of time ~15 minutes, and then it looks like I simply don’t receive any more data. I do not receive any “Close” or “Error” messages, I just don’t get anything at all.

I respond immediately to all server “Ping” requests, and also send the server a “Ping” every 30 seconds.

Typical flow looks like this.

  1. Subscribe to trade / order_book updates for 38 symbols
  2. Receive data whilst “pinging” and replying to server “pings”
    … ~15 minutes later…
  3. Send “Ping” Client → Server (Server responds with “Pong”)
    …30 seconds later…
  4. Send “Ping” Client → Server (No response from Server)
    …30 seconds later… (no order_book or trade data received from now on…)
  5. Send “Ping” Client → Server (No response from Server)

I am logging all “PONG”, “CLOSE”, “CLOSED” and “ERROR” websocket messages and don’t see anything at all.

Interestingly this exact same code seems to work fine on the futures market.

Do you have any ideas how this can happen, and how I can stop it?

This is mostly a caused by a wrongful implementation rather than the server. Please direct this question to the owner of the library you are using.

1 Like