Futures connector stops to provide updates even PING/PONG exchange continues

I need to get stable flow of all executed orders, but using this script (excluding ws_client.stop() ) binance-futures-connector-python/user_data.py at main · Binance-docs/binance-futures-connector-python · GitHub I’m getting updates on executed orders/etc only for about an hour, after that I’m getting only evergoing flow of such logging (without any updates on executed orders):

INFO:root:Received Pong from server
INFO:root:Received Pong from server
INFO:root:Received Ping from server
INFO:root:Responded Pong to server
INFO:root:Received Ping from server
INFO:root:Responded Pong to server
INFO:root:Received Ping from server
INFO:root:Responded Pong to server
INFO:root:Received Ping from server
INFO:root:Responded Pong to server

I have tried to execute each 30 minutes command client.ping() but it doesn’t help. What I should do to keep executed orders updates stable for weeks? As I understand I need to execute something else than client.ping() with some interval, plus shall I do as well something each 24 hours?

https://binance-docs.github.io/apidocs/spot/en/#user-data-streams

You need to do a put on your listenkey every hour to extend the validity or else the key will expire and you will not be able to receive any response.

Chai, thanks a lot for you help. I have found two code blocks which should work for this, can you say are they correct?

!curl -H "Context-Type: application/json" --request PUT 'https://fapi.binance.com/fapi/v1/listenKey?listenKey=API_KEY"
import requests
headers = {
    'X-MBX-APIKEY': API_KEY
}
r = requests.post( 'https://fapi.binance.com/fapi/v1/listenKey", headers=headers)

You should use requests.put instead of post.

thanks a lot, Chai!