Unstable PUT /fapi/v1/listenKey

Hello. I’m receiving way too many errors 400
“code”: -1125,
“msg”: “This listenKey does not exist.”

But its not right because for now right after this error I’m sending next request equal to first one (same key, same authorization, everything the same) and its working. What a miracle.

Log:

    [1608119452403] INFO	 (17653 on debian-socket): [WebSocket ID 1244]: Requesting listen key update
[1608119452655] ERROR	 (17653 on debian-socket): HTTP Request [Error]
    http: {
      "method": "PUT",
      "hostname": "fapi.binance.com",
      "port": 443,
      "path": "/fapi/v1/listenKey",
      "headers": {
        "X-MBX-APIKEY": "wbEaWKp8U3*******6BoFlZRmOy",
        "X-USER-ID": 1244
      },
      "httpCode": 400,
      "httpMessage": "Bad Request"
    }
    error: {
      "code": -1125,
      "msg": "This listenKey does not exist."
    }
[1608119452655] INFO	 (17653 on debian-socket): [WebSocket ID 1244]: Requesting listen key update
[1608119452691] INFO	 (17653 on debian-socket): HTTP Request [Done]
    http: {
      "method": "PUT",
      "hostname": "fapi.binance.com",
      "port": 443,
      "path": "/fapi/v1/listenKey",
      "headers": {
        "X-MBX-APIKEY": "wbEaWKp8U3*********6BoFlZRmOy", // TRUST ME ITS SAME! 100%
        "X-USER-ID": 1244
      },
      "httpCode": 200,
      "httpMessage": "OK"
    }

Its not 1 key. Its about 2-5% of 1000 keys at same time connected to binance.

But this is ok, I can handle it, But some keys just stop working at all. 3 attempts to PUT give me 400 bad request and I have to stop it. Why? Like it was 4 hours of working, 5th success PUT and for some reason stop working.

What I can do to minimize this errors?

Update: What will happen if user will be using his api key in two third party apps with web-sockets implementation at same time. Will listen key interfere? Most of my customers are using such apps.
Because many keys just receiving this error despite sending PUT quite often and using PING PONG to check web-socket connection

I still need help. Its happening all the time.

More examples:

LOGIC:
{"level":30,"time":1608281659136,"pid":1148313,"hostname":"oneart","msg":"WebSocket [249::Init]: Start command request"}
{"level":30,"time":1608281659136,"pid":1148313,"hostname":"oneart","msg":"WebSocket [249::Init]: Requesting listen key"}
{"level":30,"time":1608281659601,"pid":1148313,"hostname":"oneart","msg":"WebSocket [249::API]: Got listen key"}
{"level":30,"time":1608281659601,"pid":1148313,"hostname":"oneart","msg":"WebSocket [249::Socket]: Starting socket"}
{"level":30,"time":1608281660970,"pid":1148313,"hostname":"oneart","msg":"WebSocket [249::Open]: Started successfully"}
{"level":30,"time":1608282112532,"pid":1148313,"hostname":"oneart","msg":"WebSocket [249::API]: Requesting listen key update"}
{"level":30,"time":1608282112930,"pid":1148313,"hostname":"oneart","msg":"WebSocket [249::API]: Requesting listen key update"}
{"level":30,"time":1608282113319,"pid":1148313,"hostname":"oneart","msg":"WebSocket [249::Unsubscribe]: Stop command request"}
{"level":30,"time":1608282113319,"pid":1148313,"hostname":"oneart","msg":"WebSocket [249::Unsubscribe]: Finding socket connection"}
{"level":30,"time":1608282113319,"pid":1148313,"hostname":"oneart","msg":"WebSocket [249::Unsubscribe]: Removing socket connection"}
{"level":50,"time":1608282113684,"pid":1148313,"hostname":"oneart","error":{"message":"This listenKey does not exist.","stack":"Error: This listenKey does not exist.\n    at IncomingMessage.<anonymous> (file:///var/www/html/tmm-sockets/build/helpers/http.js:30:31)\n        -> /var/www/html/tmm-sockets/src/helpers/http.ts:36:29\n    at IncomingMessage.emit (events.js:327:22)\n    at endReadableNT (_stream_readable.js:1327:12)\n    at processTicksAndRejections (internal/process/task_queues.js:80:21)"},"msg":"WebSocket [249::Unsubscribe]: Error while unsubscribing"}

HTTP REQUESTS:
{"level":30,"time":1608281659601,"pid":1148313,"hostname":"oneart","http":{"method":"POST","hostname":"fapi.binance.com","port":443,"path":"/fapi/v1/listenKey","headers":{"Content-Type":"application/json","X-MBX-APIKEY":"JWJmtDK3mQlycse5AbNdZRjqRLbzXdsXFfTgWNo0e1GvEr2K0fOuMvRvtfTKpO2Z","X-USER-ID":249},"httpCode":200,"httpMessage":"OK"},"msg":"HTTP Request [Done]"}
{"level":50,"time":1608282112930,"pid":1148313,"hostname":"oneart","http":{"method":"PUT","hostname":"fapi.binance.com","port":443,"path":"/fapi/v1/listenKey","headers":{"Content-Type":"application/json","X-MBX-APIKEY":"JWJmtDK3mQlycse5AbNdZRjqRLbzXdsXFfTgWNo0e1GvEr2K0fOuMvRvtfTKpO2Z","X-USER-ID":249},"httpCode":400,"httpMessage":"Bad Request"},"error":{"code":-1125,"msg":"This listenKey does not exist."},"msg":"HTTP Request [Error]"}
{"level":50,"time":1608282113319,"pid":1148313,"hostname":"oneart","http":{"method":"PUT","hostname":"fapi.binance.com","port":443,"path":"/fapi/v1/listenKey","headers":{"Content-Type":"application/json","X-MBX-APIKEY":"JWJmtDK3mQlycse5AbNdZRjqRLbzXdsXFfTgWNo0e1GvEr2K0fOuMvRvtfTKpO2Z","X-USER-ID":249},"httpCode":400,"httpMessage":"Bad Request"},"error":{"code":-1125,"msg":"This listenKey does not exist."},"msg":"HTTP Request [Error]"}
{"level":50,"time":1608282113682,"pid":1148313,"hostname":"oneart","http":{"method":"DELETE","hostname":"fapi.binance.com","port":443,"path":"/fapi/v1/listenKey","headers":{"Content-Type":"application/json","X-MBX-APIKEY":"JWJmtDK3mQlycse5AbNdZRjqRLbzXdsXFfTgWNo0e1GvEr2K0fOuMvRvtfTKpO2Z","X-USER-ID":249},"httpCode":400,"httpMessage":"Bad Request"},"error":{"code":-1125,"msg":"This listenKey does not exist."},"msg":"HTTP Request [Error]"}

Got listen key. 453 second later(7 min) PUT return me {“code”:-1125,“msg”:“This listenKey does not exist.”}

Why? What happens with the key?

@MJW @dino

Should we use ?listenKey=xxxxx in PUT method?

Because in docs nothing about it:

Keepalive User Data Stream (USER_STREAM)
Response:

{}
PUT /fapi/v1/listenKey

Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It's recommended to send a ping about every 60 minutes.

Weight: 1

Parameters:

None

What Im suspecting, (because for 90% of users its working without ?listenKey=xxx)
if user have 1 listen key PUT will work all the time but if user have 2 listenKeys it will give this error. Am I right?

Yes, very helpful @tmm! Thank you, it fixed my problem :smiley:

Guys, please put it in futures api documentation. PLEASE :heart: