Delay in receiving an Event:UserDataStreamExpired from Binance Futures

Hi! There is a Python bot with a WebsocketApp module for Binance Futures. The bot sets orders and monitors their status via OrderTradeUpdate. listenKey is updated by Event:UserDataStreamExpired, that is, every 60 minutes.
The problem is the following. When launching two bots with the same API key for different trading pairs, the bots restart with new listenkeys, but after 4-5 hours one of the bots breaks the connection not after 60 minutes, but after 80. That is, Event:UserDataStreamExpired this bot did not receive from the server. For information: bots work in terminal mode on the same server. What could be the reason for such a delay in receiving an Event:UserDataStreamExpired by one of the bots?

Hi,

Does this issue happen every time you run your bot? And does it only happen when running multiple instances of the bot? Instead of waiting for Event:UserDataStreamExpired and then creating a new key each time, try sending a ping every 60mins to keep the listenKey alive.

  • Hi! Thanks for the reply. Event:UserDataStreamExpired from the server are periodically lost when starting a single instance of the bot. The WebSocketApp of the bot sends a ping every 60 seconds, and strangely, after 60 minutes, the pong response from the server returns, there is no error, and the UserDataStream has already been interrupted due to the listenKey expired. That is, the bot does not break the connection due to the presence of ping/pong and the loss of Event:UserDataStreamExpired, and no data is transmitted.

Ok so just to clarify, you’re saying that your code is already sending pings PUT /fapi/v1/listenKey every 60 seconds? So after 60minutes when it disconnects, the last successful ping would’ve been only 60 seconds prior to that?

Can you please post the snippet of code in question so I can take a look?