multiple socket connections to one account [futures]

I am still struggling with socket connection stability. Some connections(100+) work for weeks. Others constantly receive the message the key has expired. The general pattern is that clients use terminals for trading and hold several websocket connections at the same time.
I don’t know how this is related, but the problem persist in hundreds of connections to different keys.

I use everything I can, from constant ping of the server to regular key renewal. The main problem arises from the double message from the binance about the expired key. And my script works twice and apparently uses the wrong key in the future and I get a zombie connection that works, pings and even updates the key, but never again receives a message about a change in trades.

Log example:

{"level":30,"time":"2021-01-02T19:58:43.346Z","msg":"WebSocket [1176::Message]: {\"e\":\"ORDER_TRADE_UPDATE\""}
{"level":30,"time":"2021-01-02T19:58:43.681Z","msg":"WebSocket [1176::Message]: {\"e\":\"ORDER_TRADE_UPDATE\""}
{"level":30,"time":"2021-01-02T19:58:44.033Z","msg":"WebSocket [1176::Message]: {\"e\":\"ORDER_TRADE_UPDATE\""}
{"level":30,"time":"2021-01-02T20:08:52.051Z","msg":"WebSocket [1176::keepAliveListenKey]: Requesting listen key update"}
{"level":30,"time":"2021-01-02T20:08:52.051Z","msg":"Binance [1176::keepAliveListenKey]: Requesting listen key"}
{"level":30,"time":"2021-01-02T20:08:52.321Z","msg":"WebSocket [1176::keepAliveListenKey]: Listen key updated"}
{"level":30,"time":"2021-01-02T20:11:57.762Z","msg":"WebSocket [1176::onMessage]: listenKeyExpired, message: {\"e\": \"listenKeyExpired\", \"E\": 1609618317619}"}
{"level":30,"time":"2021-01-02T20:11:57.763Z","msg":"WebSocket [1176::updateListenKey]: Requesting listen key update"}
{"level":30,"time":"2021-01-02T20:11:57.763Z","msg":"WebSocket [1176::onMessage]: listenKeyExpired, message: {\"e\": \"listenKeyExpired\", \"E\": 1609618317619}"}
{"level":30,"time":"2021-01-02T20:11:57.764Z","msg":"Binance [1176::getListenKey]: Requesting listen key"}
{"level":30,"time":"2021-01-02T20:11:58.051Z","msg":"WebSocket [1176::API]: Got listen key"}
{"level":30,"time":"2021-01-02T20:11:58.051Z","msg":"WebSocket [1176::updateListenKey]: Listen key updated"}
{"level":30,"time":"2021-01-02T20:25:14.362Z","msg":"WebSocket [1176::keepAliveListenKey]: Requesting listen key update"}
{"level":30,"time":"2021-01-02T20:25:14.362Z","msg":"Binance [1176::keepAliveListenKey]: Requesting listen key"}
{"level":30,"time":"2021-01-02T20:25:14.649Z","msg":"WebSocket [1176::keepAliveListenKey]: Listen key updated"}
{"level":30,"time":"2021-01-02T20:41:36.673Z","msg":"WebSocket [1176::keepAliveListenKey]: Requesting listen key update"}

... no ORDER_TRADE_UPDATE ever after....

From what I read, the issue you see is you received “listenKeyExpired” msg too often on the same key, am I right? Theoretically it expires each hour. Please confirm you received the msg more often than this frequency. If yes, I suggest you contact Binance CS with below information provided:

  1. uid
  2. listenKey
  3. the raw message like this:
    {
    ‘e’: ‘listenKeyExpired’,
    ‘E’:XXXX
    }

Yes, you are right. As you can see in logs above I updated key at 2021-01-02T20:08:52.321Z
and 2 minutes later at 2021-01-02T20:11:57.762Z I received listen key expired.

What uid and where I can find it?

From your log, you’ve got two exact same msg for listenkey expiration; They’re expected as currently fstream sends duplicated expiration msg; Please adjust your code the ignore the second one if ‘E’ are the same